Running an emulator! 

I found it really amazing that you could so conveniently run a virtual machine on your system! When I tried installing VMWare, it was such a pain. Finally, at the end, I got it working, but I didn’t use it.

Today, I needed an emulator to test the Debian preseeded install that I’ve been working on. So I fired up the virtual machine that Varun showed me the other day:

sudo apt-get install qemu

qemu -cdrom bootable_cdrom.iso

And voila! I get a GRUB prompt (that’s what I’d put on the ISO image) that awaits a few commands in no time. That’s as far as CD-ROM boot goes.

Now, the virtual machine has no harddisk. Let’s say we wanted to give our virtual machine a harddisk – First we need to “create” the harddisk, that is if we’re not willing to dedicate a full partition to the virtual machine.  So, off we go:

dd if=/dev/zero of=new_virtual_hdd.img count=10000000

I think that produces a 5.12 GB file, if I amn’t wrong. So this time, we have a harddisk:

qemu -cdrom bootable_cdrom.iso new_virtual_hdd.img

So now you can go ahead and install any OS you want etc. But wait a minute, we want more than that – what about Network hardware?  QEMU automatically enables a kind of NAT between the virtual machines and the host macnine’s network. So internet access etc. should work as though we were behind a NAT router. As I write this, the Debian installer running on the VM tells me that my config file had a bug which I’ve to investigate, so I stop blogging here and do start working on fixing the flaw! 😀

For more information:

man qemu

Has a lot of details about the hardware that it emulates etc.

Advertisements