Using qemu on Windows (Basics)

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.

21 thoughts on “Using qemu on Windows (Basics)

  1. Nice tutorial.

    Although QEMU is fast enough,
    Sun’s VirtualBox is so much easier to use, plus it’s free.

  2. @Raden
    You want to give all the credits to Sun? ;)

    Sun bought it recently, all the credits goes to the devs who worked from the beginning….

    And BTW qemu is very small in size, and VirtualBox is 22.5MB.
    qemu for windows is some 15MB which includes a basic Linux as a sample of size 10MB.

  3. I am using the following command:

    D:\>qemu.exe -hda centos.img -cdrom CentOS-5.1-i386-bin-DVD.iso -boot d -m 768

    And I get this output:

    qemu: could not open hard disk image ‘CentOS-5.1-i386-bin-DVD.iso’

    This is the same command that I use one my linux box so I’m not sure what is happening here.

  4. I found the fix. I had to run the command as:

    D:\>qemu.exe -hda centos.img -cdrom CentOS-5.1-i386-bin-DVD.iso -boot d -m 768 -L “C:\Program Files\qemu”

    The -L “C:\Program Files\qemu” was the fix.

  5. Ok, maybe this is stupid but my Qemu opens in a window bigger than my computer screen. For the life of me I can’t shrink it. I want to see the full screen – not part of it. Suggestions?

    • Well, I am not on windows right now, so can’t suggest you. As I googled and tried to find out Ctrl+Alt+F seems the fix. Try it out and tell.

  6. i m trying to open qemu.exe and qemu-img.exe after extracting them in a folder…..
    i m getting a window appears on screen just for a while after clicking..then it disappears automatically…
    can anybody help me,pls??

  7. I use qeum 0.11.1 on windows XP and I got the following message.

    $ qemu linux.img
    VNC server running on `127.0.0.1:5900′

    Do I need VNC server software installed and configured in order to run the linux image?

  8. Your steps wording color is yellow against a white background.Unless we all have x-ray capabilities in our eyes, unlike yours, we all can’t see the words.

  9. qemu.exe -cdrom isoimage.iso -boot d
    this command on executing gives an error
    could not load PC BIOS ‘c/Program Files/Qemu/bois.bin’
    but bios.bin file is there in Qemu folder in Program Files

    Please Help

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s