Qemu Headless Install

Posted Thursday 25 May 2017 by Urs Riggenbach.

I use qemu to virtualize appliances on my servers, and I access them over SSH. Allthough SSH supports streaming X windows so it is possible to fire up a graphical install, it is not so convenient as the connection may drop and cancel the install.

A convenient workaround is to use qemu’s curses/nographic interface, where instead of a display, a terminal is attached to the virtual machine. That way you can install and use your virtual machines directly in the SSH terminal.

To install a new system from scratch, simply define the -hda, -cdrom and -boot flags, and add the -nographic option:
qemu-system-x86_64  -hda /dev/sdc1 -m 1500 --enable-kvm -nographic -cdrom images/debian-stable.iso -boot d

The Debian installer supports headless mode, but we have to add two settings at the boot prompt to make it work with curses/nographic.

1. Fire up qemu with the command above. Wait a few seconds, the screen will turn black after loading syslinux. Hit ESC, and enter:
install fb=none vga=normal

and follow the install. VoilĂ , you’re installing your VM in qemu directly over ssh.

Tip: To prevent losing the install if the network connection is lost, run the commands in a screen terminal.