Before installing this Windows emulator, consider whether or not it's truly necessary for you. In most cases, its functionality is provided by a free Linux program (see SoftwareEquivalents).
Consider also Wine instead of Qemu, if you only need to run a single Windows program.
Most of the stuff in this page is not specific to installing Windows XP under Qemu; it can be used to install other operating systems as well.
See also Installation/QemuEmulator.
NOTE: Changes made to the Ubuntu Gutsy Gibbon and Hardy Heron distribution code have broken the USB functionality in QEMU. If you need USB functionality with QEMU please see the details here: here .
Running Windows Under Ubuntu 7.04/7.10
This method also works perfectly under Ubuntu 8.04
QEmu can run an OS inside another OS - for example, Windows under Linux. QEmu uses kqemu, an acceleration driver included in Ubuntu 7.04 Feisty Fawn to run Windows at usable speed. Note: KQEMU will not work under Ubuntu 10.04. See KQEMU page for more info Ubuntu 7.04 Feisty Fawn also includes a new version of rdesktop that can be used to start individual desktop apps from the VM on your normal desktop. See SeamlessVirtualization. This also works in Ubuntu 7.10 Gusty Gibbon. Note: Most computers purchased since 2006 support VT or Pacifica, technologies that provide hardware support for virtualization. To see if your system includes these technologies, run the following: If there are any results and you have Hardy 8.04, install the 'kvm' package, skip to step 10 and replace 'qemu' in the commands with 'kvm'. Also for multicore machines enjoy the benefits of using '-smp 2' as an option. For older versions of ubuntu see Kernel Virtualization as another possibility for virtualizing other operating systems. Note: Even if you get no output from the above command, your computer may actually support virtualization in hardware. Some machines are delivered with hardware virtualization disabled in the BIOS. Other machines require an update to the latest BIOS to enable virtualization. To install
While the following guide uses Windows XP, older versions of Windows work fine, and may be preferred due to their increased speed. and see if that clears the problem. If not, add OWNER="youruser" to the end of the udev rule and try again Note: If you want to install Windows XP Service Pack 2 + Updates, 2 GB is not enough for the image size. Use at least 3-4 GB. Note: Consider using as much disk space as you can afford. Resizing NTFS partitions isn't fun, and hard disk space is cheap. Note: If you use qcow images, you will not be able to mount the image within Ubuntu. You can omit '-f qcow' and create a mountable image, but this will mean that the size of the virtual drive will be fixed and larger. Instructions to convert a raw drive to a qcow drive appear at the end of this page. Note: Your CD drive might be under a slightly different name like /dev/cdrom1. Go to /dev to see what location you should use. Note to 64 bit users: Use 'qemu-system-x86_64' instead of 'qemu'. Otherwise the "-kernel-kqemu" option will not work. Note for Windows 2000: Add the option '-win2k-hack'. Otherwise the install may fail with "Not enough disk space" even when that isn't the case. Note to 64 bit users: Use 'qemu-system-x86_64' instead of 'qemu'. Otherwise the "-kernel-kqemu" option will not work. Note for Windows 2000: Add the option '-win2k-hack'. Otherwise the install may fail with "Not enough disk space" even when that isn't the case.
QEmu provides two modes of networking. In both modes, a virtual network adapter is created inside Windows XP guest.
In user mode networking, QEmu manages network interface internally in the user mode emulator application. QEmu provides DHCP host which assigns a dynamic IP for the guest OS. TCP and UDP ports can be redirected from the host OS to the guest OS using QEmu command line parameters. Pros Cons
In TAP networking, QEmu connects the guest OS ethernet to the host OS using TAP network bridge. Linux creates a network interface (tap0) which appears in the ip addr listing, as do other interfaces. Furthermore, it is possible to bridge network traffic to the guest OS using normal Linux network bridging functionalities. For examples, see following pages Pros Cons
This is an alternative to TAP networking. Most of this is from the page KVM - Advanced Networking and http://compsoc.dur.ac.uk/~djw/qemu.html. Caution: The following package, "dnsmasq" provides dns, tftp and dhcpd services. An LTSP standalone server would be affected because dnsmasq would interfere with the dhcpd and tftp services. * Install the packages vde dnsmasq: * In the file /etc/sysctl uncomment the following line to allow IP forwarding: * In the file /etc/modules, add a new line with "tun", to make that module load on boot. * Add the new network interface. Edit the file /etc/network/interfaces and paste this: Temporary vdeq control sockets are created in /tmp, the vde_switch socket in /var/run/vde.ctl/ , and the management socket is /var/run/vde.mgmt . More info about vde_switch (VDE): http://wiki.virtualsquare.org/index.php/VDE * Configure DNSmasq. Edit the file /etc/dnsmasq.conf and change the following options: To avoid the need for root privileges add the group "vde2-net" to all users that will use VDE (log-out and log-in for this to take effect) Either restart the PC or simply do: Then you will have a virtual network on qtap0 interface. VM will be able to connect to the Internet (because of the iptable line on /etc/network/interfaces), but will not be accessible from it. To run a VM with the virtual network use vdeqemu instead of qemu: In Karmic, there is no vdeqemu, rather, package vde2 provides a simple wrapper. Instead of the above command, substitute vdeqemu with vdeq qemu, or vdeq qemu-system-x86_64, and then the rest of your options, thus: or if using a 64-bit host, See KVM Advanced Networking - Permanent Setup- for more details on using qemu-launcher and qemuctl with VDE and KVM hardware virtualisation
It's not much use having an XP installation if you can't transfer files between Ubuntu and XP. Fortunately, QEMU sets up a virtual LAN and DHCP server for you. You can transfer files to and from XP just as if it was on a real LAN. You can also browse the net and download files and do all the network stuff you would do on a real networked XP box.
QEmu supports file sharing between the VM and host if you have Samba configured on the host system. The following assumes you have a share called 'qemu_share' in your home directory intended to transfer files between Ubuntu and Windows. To set this up, start QEmu with the following command: Inside Windows, you can access the shared drive with the following command from a DOS prompt. For example, to map Windows drive 'e' to the share The IP address of Ubuntu will always be 10.0.2.2. If you have running servers on your Ubuntu box, they can also be accessed at this IP address (e.g. ftp://10.0.2.2)
NOTE: Changes made to the Ubuntu Gutsy Gibbon and Hardy Heron distribution code have broken the USB functionality in QEMU. If you need USB functionality with QEMU please see the details here: here . QEmu can emulate a USB tablet input device instead of an ordinary mouse. Since a tablet reports the pointer position in absolute coordinates, it is possible to have the guest pointer track the host pointer position directly without a mouse grab. Running QEmu with the command line options "-usb -usbdevice tablet" enables USB emulation and the tablet input device: Windows XP automatically uses the tablet without having to install any additional drivers. (TODO: Maybe these options should simply be added to the default ones at the top of the page. Not everyone will find this paragraph, and the feature is so useful that it should probably be recommended for general use. --DanielElstner)
You can also mount the QEmu virtual disk just like any other drive. QCOW images cannot be mounted. If the drive was created in qcow format you'll need to convert it first, see below. Make sure you are NOT running QEMU when you do this. Windows will not recognize anything you write while running QEMU. Even worse, it will perceive that something changed and will run the chkdsk the next time you start QEMU. Also, you may only be able to read something wrote by windows after the windows is closed. To mount the drive, create a directory '/media/qemu'. Then run Or you can have it automatically mounted by adding the following line to /etc/fstab
You can quickly save and restore the state of your Windows System using QEmu's 'overlay images'. Once you have done your initial install, you can create an overlay image and run QEMU off this. The overlay image is very much smaller that the original image and will only contain changes made since the original install. If you trash your XP installation, you can simply delete the overlay image and create a new one from the original image. To create an overlay image, use the qemu-image program. To create an image windows.ovl from windows.img, issue the following To run Windows, you would now use If the winxp.ovl installation is ruined, you can delete it, and start QEmu using the winxp.img file. But you will lose changes made since the original install.
With the option -snapshot, QEmu writes to temporary files instead of disk image files. In this case, the raw disk image you use is not written back. You can however force the write back by pressing C-a s. The snapshot mode if useful to try a program that you don't trust (you should never trust a closed source program).
QEmu also accepts commands from the shell while it is running. To do this, though, you need to press CTRL+ALT+2 with the QEmu window active. This brings up the QEmu Monitor. From here, you can swap CDs, send keypresses to the emulator, suspend to disk and so on. See the official documentation for full details. To exit the QEmu monitor press CTRL+ALT+1
To convert a qcow image, 'windows.img', to a raw 'windows.raw' file , run
To convert a raw 'windows.img' file to a qcow formatted 'windows.qcow', run
If you experience problems with mouse pointer hanging in bottom right corner, try before you start up qemu If you experience the guest Windows XP hanging after the mouse is captured, try this option
This has been tested by me and works in Ubuntu 7.10 Gutsy Gibbon. Vaderdarth211 This has been tested by me and works in Ubuntu 8.04 Hardy Heron. Paulx2
Install package qemu and one of the qemu gui helpers (I used Qemu Launcher). Set it to create new empty image (I set it for 10Gbytes). Set to boot from CD. Set RAM size to about half your RAM (for installation I have set the same and it worked thou). Hit 'Launch'. The system will boot from CD and install itself, make sure to hit F12 to select boot from hard disk when the first reboot occurs. Tested on : Pentium M 1.4GHz, 512M RAM (Dell Lattitude D600 laptop, Windows installed from CD accompanying this laptop, WinXP professional). No mention of any hardware virtualization in /proc/cpuinfo. And no BIOS upgrade either to enable if any. Graphic :set to Cirrus Logic compatible; Impressions : Installation takes some 12 hours in total It is surprisingly responsive even when RAM size is set to 256M. el_es
grep -E '^flags.*(vmx|svm)' /proc/cpuinfo
Installing Windows in QEmu with Feisty 7.04 and Gutsy 7.10
sudo module-assistant prepare
sudo module-assistant auto-install kqemu
cd /usr/src/kqemu*
sudo ./configure
sudo make
sudo ./install.sh
gksudo gedit /etc/udev/rules.d/60-kqemu.rules
with the following content: (the order of GROUP and MODE seems to matter, so be sure to add a new line at the end of the file) KERNEL=="kqemu", NAME="%k", GROUP="kqemu", MODE="0660"
options kqemu major=0
sudo addgroup --system kqemu
sudo adduser $USER kqemu
sudo /etc/init.d/udev reload
sudo update-modules # this is deprecated under Hardy, instead use "sudo depmod -a"
sudo modprobe kqemu
$ ls -l /dev/kqemu
crw-rw---- 1 root kqemu 10, 62 2007-07-22 15:36 /dev/kqemu
sudo modprobe -r kqemu
sudo modprobe kqemu
gksu gedit /etc/modules
qemu-img create -f qcow windows.img 2G
qemu -localtime -cdrom /dev/cdrom -m 384 -boot d windows.img
qemu -localtime -cdrom cdimagefile.iso -m 384 -boot d windows.img
chmod 660 windows.img
sudo chown $USER:kqemu windows.img
Networking
User mode networking
QEMU VLAN <------> Firewall/DHCP server <-----> Host network
| (10.0.2.2)
|
----> DNS server (10.0.2.3)
|
----> SMB server (10.0.2.4)
TAP network
VDE and Dnsmasq
sudo apt-get install vde dnsmasq
net.ipv4.conf.default.forwarding=1
auto qtap0
iface qtap0 inet static
address 10.111.111.254
netmask 255.255.255.0
pre-up /sbin/modprobe ipt_MASQUERADE
pre-up /usr/bin/vde_switch --tap qtap0 --sock /var/run/vde.ctl \
--daemon --group vde2-net --mod 775 \
--mgmt /var/run/vde.mgmt --mgmtmode 770 \
--pidfile /var/run/vde_switch.pid
pre-up /etc/init.d/dnsmasq restart
up iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
down iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
post-down kill -s HUP `cat /var/run/vde_switch.pid`
user=nobody
domain=qemu.lan
interface=qtap0
dhcp-range=10.111.111.1,10.111.111.253,255.255.255.0,10.111.111.255,8h
sudo usermod -aG vde2-net $USER
sudo sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo modprobe tun
sudo ifup qtap0
vdeqemu -net vde,vlan=0 -net nic,vlan=0 -m 384 -boot c windows.img
vdeq qemu -net vde,vlan=0 -net nic,vlan=0 -m 384 -boot c windows.img
vdeq qemu-system-x86_64 -net vde,vlan=0 -net nic,vlan=0 -m 384 -boot c windows.img
Additional Options
Sharing Files With XP and Networking
Sharing Files between the Host and VM
qemu -smb $HOME/qemu_share -m 384 -localtime windows.img
net use e: \\10.0.2.2\qemu_share
USB Tablet Emulation
qemu -m 384 -localtime -usb -usbdevice tablet windows.img
Mounting A Virtual Drive
sudo mount -t ntfs -o loop,offset=32256 windows.raw /media/qemu
/home/user/windows.raw /media/qemu ntfs rw,user,loop,offset=32256 0 0
Saving and Restoring the State of the VM
qemu-img create -b windows.img -f qcow windows.ovl
qemu windows.ovl -enable-audio -user-net -localtime -smb qemu_share
Snapshot mode
QEmu Monitor
eject cdrom
change cdrom /path/to/some.iso
Converting a qcow image to a raw file
qemu-img convert windows.img -O raw windows.raw
Converting a raw drive to qcow format
qemu-img convert windows.img -O qcow windows.qcow
Troubleshooting
export SDL_VIDEO_X11_DGAMOUSE=0
-usb -usbdevice tablet
External Links
Under 9.04 (Jaunty)