Wednesday, December 12, 2007

Installing Ubuntu 7.04 Server on QEMU

I was able to install and run an Ubuntu 7.04 Linux (Server Edition) on a Windows XP host using QEMU. Installation was pretty straightforward, what required some extra research was getting the Linux guest OS to communicate with the host OS using TCP/IP.

Here are the steps:

Ubuntu Installation

1. Download and install QEMU for Windows

2. (Optional) Download and install KQEMU for Windows

This will greatly speed up the virtual machine running in QEMU.

3. You will also need to download the Ubuntu server .iso file.

4. Once these are ready, you can create the disk image that will be used by the virtual machine.

The command line below will create a disk image 3GB-large in the file ubuntu.img:

qemu-img.exe create ubuntu.img 3G

5. Boot the virtual machine with the Ubuntu .iso as CD-ROM drive

qemu.exe -cdrom ubuntu-7.04-server-i386.iso -boot d -m 256 -L . ubuntu.img

You should see a window with the Ubuntu installation screen.
Proceed with the installation as per normal.

After installation, you need to reboot with the disk image as boot disk. Just remove the -boot d option to do this.

qemu.exe -cdrom ubuntu-7.04-server-i386.iso -m 256 -L . ubuntu.img

Voila! A Linux box (with LAMP) right inside your Windows desktop.

Configuring the Network

There are a couple of ways to go about this, and it really depends on your network configuration (i.e., whether you use DHCP, whether you need to connect to the Internet, etc.). The steps below describe what I did in my set-up:

1. Download and install OpenVPN.

Actually you will just need the Tap-Win32 component, so you can go ahead and de-select the other components during installation.

2. After installation you will have a new "Local Area Connection" in your Network Settings folder. For convenience later, I suggest you rename this to something like tap0.

This interface will be used to connect to the guest OS. You can assign it an IP address, e.g. 192.168.1.1.

3. Boot the guest OS, but this time add the ff. parameters: -net nic -net tap,ifname=tap0

This will give the virtual machine a network interface, and connect that network interface to the host's tap0 interface.

4. After the Ubuntu server has booted, it should have an eth0 interface. You can assign an IP address to this using ifconfig.

$ ifconfig eth0 192.168.1.2

That's it. Your host OS and guest OS should have network connectivity! Try to ping each other. Your network should look like this:

192.168.1.2(eth0, linux) <----> 192.168.1.1(tap0, windows)

If you want to connect the linux box to the Internet then you can use the bridging function of Windows. I also suggest turning on the Samba server of the linux box so that transferring files between OSes will be very convenient.

Happy emulating!

No comments: