Boot a VM from an ISO and redirect the ouptut to the console

Printer-friendly versionSend to friend

Let's imagine that you have a server which is only accessible over ssh and want to install a virtual machine with kvm or qemu on it based on an Ubuntu server ISO or alternate CD. The logical way to perform this install would have normally been to use a VNC connection to perform the installation, but your machine is so far away that the latency renders this option almost unuseable. Here is a way to do this by redirecting the console output to the terminal and bypass the initial graphical boot screen. 

  1.  Mount you iso as a loopack on /mnt

    #mount -o loop hardy-server-i386.iso /mnt

  2. Create a new empty virtual disk image

    #qemu-img create -f qcow2 -c disk.qcow2 2G

  3. Start your qemu or kvm machine using the following command (the parameters are the same for qemu or kvm)

    #kvm -kernel /mnt/install/vmlinuz -initrd /mnt/install/initrd.gz -append 'file=/cdrom/preseed/ubuntu-server.seed initrd=/install/initrd.gz quiet console=ttyS0 --' -cdrom hardy-server-i386.iso  -nographic -hda disk.qcow2

Note that qemu only supports 32 bit images, use qemu-system-x86_64 for 64 bit images.  Kvm will support both 32 and 64 bit though.

Thanks to Soren Hansen helping me figuring this one out.  Hope it can be useful to someone else.

Share/Save