This question occurs to me when I am trying to have the guest Ubuntu OS display boot messages in QEMU VM (like [ 2.34567890123] ... and [ OK ] ....). Here I have a QEMU VM, both the host and guest being Ubuntu 20.04. To display guest's boot messages in host's console (i.e., command line that starts qemu), I set some lines of the guest's /etc/default/grub
file as follows:
GRUB_TIMEOUT_STYLE=menu
GRUB_TIMEOUT=5
GRUB_TERMINAL_OUTPUT=console
GRUB_CMDLINE_LINUX_DEFAULT=nomodeset
Then I start the guest using the following command:
qemu-system-x86_64 -hda ubuntu.qcow -m 2000 -nographic -serial none
GRUB outputs its TUI by either serial or VGA text mode. -nographic
disables the VGA output and -serial none
disables the serial console, so I cannot see any GRUB TUI. Only the QEMU monitor displays in the console. According to the documentation of -nographic
(here), "QEMU is a simple command line application" in this situation. Like normal C/C++ program, QEMU monitor uses printf
(or other function, but please allow me to use this name as an expedient) to display its versions, prompts and other messages. After 5 seconds, Ubuntu guest OS is booting. However, I can not see any boot messages printed in the console. My previous experiments shows that Ubuntu does not use serial console, Instead, it uses VGA text mode for output. For this reason, I am guessing, if Ubuntu can use the same printf
function to output its boot messages, QEMU should be able to display them in console (muxed with QEMU monitor), just like how QEMU monitor's outputs are treated. Based on the observation that the console has only the output of QEMU monitor, my question is:
Does Ubuntu not use printf
for output at boot, expressly or by default, perhaps due to performance consideration? If it's a default behavior, what boot option can I use to force Ubuntu to use printf
to output its boot message (or any output method that QEMU moniter uses), as opposed to VGA text mode? As a side note, I googled but did not find any online documentation on Ubuntu boot options like nomodeset
, so I don't know if there is any Ubuntu boot option that can specify this. Please share its link with me if you know it. It's a lot of work so I can't say for sure I have mentioned everything above. If I missed mentioning something in the question, please let me know and I will edit. Thanks.