As of 2017, qemu doesn't provide text-mode-only graphics card emulation for x86-64 that would force a guest to stay in text mode.
Current distributions like Fedora 25 come with the bochs_drm
kernel module that enables a frame buffer (e.g. 1024x768 graphics mode), by default. In contrast to that, e.g. Debian 8 (stable) doesn't provide this module and thus it stays in old-school text-mode during the complete boot.
Thus, when running qemu from a terminal (e.g. with -display curses
) it makes sense to enable a serial console as fail safe:
console=tty0 console=ttyS0
or
console=tty0 console=ttyS0,115200
(Kernel parameters for the guest, default speed is 9600, both settings works with qemu, make the settings persistent in Fedora via assigning them to GRUB_CMDLINE_LINUX
in /etc/sysconfig/grub
and executing grub2-mkconfig -o /etc/grub2.cfg
or grub2-mkconfig -o /etc/grub2-efi.cfg
)
In case nothing else works one can then switch inside qemu via Alt+3 to the serial console, then.
A second measure is to disable the framebuffer via a bochs_drm
module parameter - i.e. via setting it on the guest kernel command line:
bochs_drm.fbdev=off
Blacklist Alternative
Alternatively, the bochs_drm
module can be blacklisted - i.e. via creating a config under /etc/modprobe.d
- say - bochs.conf
:
blacklist bochs_drm
Since the initramfs mustn't load the bochs_drm module, as well, one has to make sure that this config is included into the initramfs. On Fedora like distributions this is achieved via:
# dracut -f
UEFI Boot
When booting qemu with an UEFI firmware (e.g. -bios /usr/share/edk2/ovmf/OVMF_CODE.fd
) the disabling of the bochs fbdev isn't enough. The Fedora boot then hangs while trying to switch to the bochs framebuffer. Blacklisting the bochs_drm fixes this but it isn't sufficient. One just gets a 640 x 480 graphics mode that isn't reset to text mode by the kernel. Thus, for UEFI guests one has to take the serial console route.
Serial Console
Using the serial console in combination with -display curses
yields a suboptimal user experience as the curses interferes with the vt110/vt220 terminal emulation. Thus, it only suffices for emergencies.
A better solution is to completely switch the display off and use the combined serial/monitor Qemu mode:
-display none -serial mon:stdio -echr 2
(where Ctrl+b h displays a help and Ctrl+b c switches between the modes)
With Fedora 27, the Grub2 is configured with serial console support, by default. Thus, it can be controlled via the serial terminal, as well.
Calling resize
after login updates the terminal geometry, thus, the resulting terminal behaves as good as a local one.
Multi-User Target
In case the guest image has a graphical login manager installer it makes sense to disable it:
# systemctl set-default multi-user.target
Otherwise, on has to switch to the first virtual console after each boot (e.g. Alt+2 or Alt+3 when using the curses display).
Best Answer
KMS-enabled kernels overrule any
vga=
setting beforeinit
completes, when modesetting is initiated, functionally making whethervga=ask
works or not moot.Instead, use
video=
with the specific mode desired on the vttys. Withvideo=
, you're not limited to VESA modes - any mode supported by the display can be used. It's even possible sometimes withvideo=
to specify modes that a display doesn't natively support, though the result can be ugly, e.g. 2048x1024 on a 1920x1200 native display.See https://www.kernel.org/doc/Documentation/fb/modedb.txt for video= documentation.