Friday, January 23, 2009

Some experiments with Qemu

For the last two days I have been playing around with Qemu a bit. The system administrator had installed qemu in my office desktop. As an experiment I tried to install a minimal debian system on it. I downloaded the debian net-installation CD image just because it was the smallest and good for experimenting. With qemu installed and with the iso image of the CD on the hard disk I started the installation step by step.

First the virtual computer should have some virtual hard disk space. Qemu provides a tool to do that. I used the command

$ qemu-img create -f qcow debinst.qcow 5000000

Yes the "create" command creates the hard disk. The switch "-f" specifies the format. I used the native qcow format for the disk as I read that it is the best and it takes less amount of space on your "actual harddisk". So a 5GB virtual harddisk after installating debian took a little less than 1GB of actual harddisk space.

Note I saved my cdrom image (debian.iso) one level below the directory where I am presently in. So for the installation I ran the command

$ qemu -hda debinst.qcow -cdrom ../debian.iso -boot d

So it says qemu to take debinst.qcow as the harddisk for the virtual computer and ../debian.iso as the content of the CD in the cdrom drive. -boot d tells it to boot from the cdrom.

The debian installer kicked in and the installation was smooth. For my experiment I used the guided partitioning with just two partitions; one for the root and one for home. I did not install any extra packages other than the standard ones initially. I actually don't need a graphical interface, so I did not bother to install any desktop environment either. My installation only has the console interface and I am happy with it.

Later on I had installed build-essential just for my programming interests.

Then I wanted to use this installation from my slow dial-up connection from home. (You must be wondering why... Well I don't know... My answer would be just for fun!!!) The problem was it was too slow to forward X over ssh and use qemu. Specially since I am only using the console it does not make sense to forward X, I found out that qemu has the -nographic option. But somehow it was doing nothing if I tried to run

$ qemu -nographic debinst.qcow

Later on I found that

$ qemu -nographic -curses debinst.qcow

did exactly what I wanted. Now I can run qemu from the linux console without having to use X at all.