Month: July 2008

Have you ever felt an urge to use Linux in your office but you are not allowed to install it without permission. Additionally you are not allowed the partition the Hard Disk. What could be a solution? Very simple, get a Virtual Machine. Now again a new problem comes up- Virtualizing softwares are quite big and take for example VMWare are too big itself to be handled and cant be kept hidden on your computer.

This is my experience what I did when faced these problems. I downloaded qemu for Windows and also the ISO of the Linux I wanted to use. In my case it was Xubuntu as I wanted a lightweight distro. First of all you dont need to install qemu at all, just unzip it and keep it in any folder of you choice. Neither do you have to add any Product key or anythin of the sort. Here it the step by step proceedure what needs to be done to make a Virtual copy of Linux running on yor system.

1. Get a copy of the ISO of your Operating System

I wanted to install Linux – Xubuntu and download a copy of it from the main website. You can get any OS, doesnt need to be Xubuntu. It can be OpenSolaris, OpenBSD, FreeBSD or Windows itself

2. Create a virtual Hard Disk

This step is useful only if you want to install the OS, if you intend just to run LIVE without installing, you can skip this stage.

qemu-img.exe create filename 4000M

Where filename is the name of the file you are intending to use as a Hard Disk and 4000M means the size of the file is 4000MB. To create files of size more than 4GB you need to be on NTFS Filesystem as older ones cant handle such large files.

3. Start the OS in Live Mode

In this case you dont need to have a Hard Disk, just an ISO required. Boot from it using the command

qemu.exe -cdrom isoimage.iso -boot d

In this case isoimage.iso is the file which contains the ISO and is to tell that you want to boot from CD. In this case you have chosen to make CDROM as an ISO.

4. Install the OS on the Disk you created

In this you need to have the Disc created along with the ISO, use this command

qemu.exe -cdrom isoimage.iso -hda filename -boot d

The above command means that you chosen ISO as the CDROM, filename as First Hard Disk (hda) and you wanted to boot from CDROM ( -boot d )

Install from the ISO, when it is complete, just exit from qemu.

5. Starting an installed OS

This case is when you have installed from the ISO and want to use it regularly. In this case just issue the command

qemu.exe -hda filename -boot c

Here -boot c tells to boot from the first Hard Disk, you dont need -cdrom option as you have already installed the OS. You can have more than one hard disk, by specifying the -hdb ,-hdc and -hdd option, but you can only boot from -hda.

Tips:

I was not able to connect to network even after specifying a lots of options. If your network doesn’t work and you want to have some files on the guest OS, then download it on host OS, make an ISO from all those files using some tool like MagicISO. Then before starting the Virtual Machine, specify this ISO in the -cdrom options but use -boot c option itself to boot from the hard disk. Now when you are inside the OS, just mount the ISO using the command

mount /dev/scd0 /media/cdrom

Dont ever close the running Host OS using the close button of available in windows. Maybe you might not understand why at the first glance, but you can corrupt your data or installation. Dont even try to open two instances of the Guest OS using the command two times using the same Hard Disk file. You can badly screw up your installation.

-boot option can be used to control the boot priority as you did in BIOS settings. ‘a’ means floppy drive, ‘c’ means Hard Disk and ‘d’ means CD Drive.

Since you can have more than one Hard Disk you may be tempted to use the Hard Disk images in any order you want. This is highly unrecommended because MBR is only on the first Hard Disk. If you have Second Hard Disk on hdb when installing, swapping them too may lead to unbootable state as the Second Hard Disk doesnt have a MBR.

You can even start the Guest OS in full screen mode using the -full-screen option

Lastly, qemu can even access your Host OS’s hardware itself. You can install Linux/OpenSolaris etc on the physical partitons itself. You can directly access the physical CD Drive inside the Guest OS. All these would be covered in the next Tutorial.