The Best of Both Worlds

Running Linux inside Windows using QEMU.
Making QEMU Run Faster

To make the emulated system run faster, I installed kqemu. I downloaded kqemu-1.3.0pre11.tar.gz from the QEMU download page and extracted it inside D:\QEMU\. Then, I clicked kqemu.inf with the right-mouse button and selected Install. Next, I added, in start-linux.bat, the command net start kqemu and added the parameter -kernel-kqemu to qemu.exe. Now, the last two lines of start-linux.bat look like this:

net start kqemu
qemu.exe -L . -m 256 -kernel-kqemu -hda \\.\PhysicalDrive0 
 ↪-soundhw all -localtime

Note: Scientific Linux 4.4 does not work at all with the parameter -kernel-kqemu, and the problem seems to be an incompatibility of the kernel with the BIOS file (which is named bios.bin, and I think that represents the BIOS configuration of the emulated system). When I replaced it with the BIOS of Puppy Linux, it worked. It is strange that the original BIOS is 128KB and Puppy's BIOS is 64KB, which is older as well.

Accessing Windows and the Internet from Linux

The default QEMU parameters for the network are -net nic -net user. This means that it will emulate a virtual interface on the Windows side and create a network interface eth0 for the emulated Linux system. Both of these interfaces have a virtual connection between them, allowing them to communicate with each other. The IP of the Windows virtual interface is, and QEMU also creates a virtual DHCP server connected to it. To get an IP for Linux from the QEMU DHCPD, I log in as root and give the command dhclient. Then, the Linux interface gets IP, gateway and DNS Afterward, Windows and the Internet can be accessed from Linux without a problem.

Figure 2. Network Diagram

To check the network configuration, try the commands ip address ls, ip route ls and cat /etc/resolv.conf in Linux. Here's example output from those commands:

[root@fedora6 ~]# ip address ls
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet scope host lo
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet brd scope global eth0
3: sit0: <NOARP> mtu 1480 qdisc noop
    link/sit brd

[root@fedora6 ~]# ip route ls dev eth0  proto kernel  scope link  src
default via dev eth0

[root@fedora6 ~]# cat /etc/resolv.conf
; generated by /sbin/dhclient-script

To test the network connection, try the commands ping and wget

If you try to ping (or any other IP), it won't work. However, the network connection is okay and working, and you can verify it with other tools, such as wget or lftp. It simply means that ping is not working for some reason. This has been very misleading to me, because the usual way to check for network connectivity is to ping something out there.

Accessing Windows Files from Linux

Because I can ping Windows from Linux as, I also can access any service (dæmon) that runs on Windows. In particular, I can access any file-sharing services. Usually, I run Apache as a Web server on Windows. It can be installed easily with EasyPHP. Then, I use wget to retrieve any files that are accessible through the Web server.

Another service I use is FTP. I install and configure it using the FileZilla FTP server. From Linux, I can access the folders (directories) that are shared by the FTP service, using lftp (you can use any other ftp client as well). This is better than using a Web server, because I can transfer files both ways—from Windows to Linux and from Linux to Windows.

I've even used svnserve to run a Subversion service in Windows. From Linux, I could access the Subversion repositories in Windows. Think of it as a way to transfer files between Windows and Linux, as you can access the svn repositories from both Windows and Linux, although it is not a very straightforward way to transfer files.

I tried transferring files between Linux and Windows using a fat32 partition, which can be accessed from both systems. Theoretically, there is no reason why it should not work, and actually it does work; however, it does not work so well. The problem is that the modifications that are done to fat32 from Linux are not “seen” from Windows until it is restarted, and the modifications that are done from Windows are not “seen” from Linux until QEMU is restarted, which makes this solution impractical and unusable.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Booting Windows from Linux via Qemu

jmit7521's picture

The article is great and I successfully booted my Linux installation via Qemu. I am interested in booting my Windows installation from the Linux side using Qemu. If you have any suggestions please post them.


I have tried (months ago)

Dashamir's picture

I have tried (months ago) with something like: '-hda /dev/hda' , and I remember that I have failed.
Anyway, a QEMU virtual machine has different "physical" devices compared with your real machine.
So, if the windows partition is booted inside it, I guess that it is going to find "new hardware" etc.
It is something similar to removing the hard disk and booting it inside another machine.
While linux is flexible enough to endure this kind of migration, I am not sure about windows, it has
to be tried.