Running A Windows Partition in VMware - Oopsilon
Running A Windows Partition in VMware - Oopsilon
com/Running-a-Windows-Partition-in-VMw
I have my system partitioned into two: one part of the hard drive hosts a Windows XP partition, and the other
runs Gentoo Linux. About a month ago, I was just about tired of having to reboot to switch between the two, so
I decided to set up a VM for Windows.
There was, however, a snag to this: I wanted to use the existing Windows installation, because I'd tuned it up
and installed the software I always use. I expressly didn't want a virtual disk image duplicating my Windows
drive, since I didn't have the space for that. So, that was the task: running the Windows partition in a VM.
I hunted around the 'Net, and found surprisingly little information on this: the procedure I finally threw together
was sourced from many disparate places. So, in one place, I've put together the steps you'll need to take in
order to get a Windows partition running inside a VM.
VMware Player:
The easiest way to get a finished VM running; all you need to do is point the VM information file at vmplayer,
and you're good to go.
VMware kernel modules for Linux:
All VMware products on Linux use kernel modules to get monitoring and networking functionality working, so
you'll need those.
A text editor:
We'll be doing some hacking of configuration and VM information files, which means your favourite text editor.
GNU Parted:
In order for us to tell VMware about the hard disk, we need to know a few things about the disk; we'll also be
doing a little hacking of the partition table. Parted allows us to do this from the command line, and quite easily
too.
On a Gentoo Linux installation, you can get the software you need on the Linux side from the following
command (on other distributions, check your associated documentation):
1 of 9 07/25/2007 11:25
Running a Windows Partition in VMware - Oopsilon http://oopsilon.com/Running-a-Windows-Partition-in-VMw
ddb.toolsVersion = "6530"
ddb.adapterType = "ide"
ddb.virtualHWVersion = "4"
ddb.geometry.sectors = "63"
ddb.geometry.heads = "240"
ddb.geometry.cylinders = "1559"
The values highlighted in red are ones you'll need to change, depending on the characteristics of your hard
disk: they describe my disk quite well.
Now you can fire up Parted against the disk you want to use. If you have Windows on one hard disk and Linux
on another, use the Windows disk in the command below, otherwise just use the disk device containing the
Windows partition.
Note the unit s command, which tells Parted to print out its values in terms of disk sectors: we'll be using
these values in the VMDK file. Also note the second unit command, to provide the values in cylinders; that
allows us to fetch the disk geometry in CHS format.
2 of 9 07/25/2007 11:25
Running a Windows Partition in VMware - Oopsilon http://oopsilon.com/Running-a-Windows-Partition-in-VMw
The values in red are the ones we'll be using. But not so fast; before you plug the values in, we'll need to do
some calculation. Instead of using the hard disk's standard boot sector, which allows you to boot Windows or
Linux, we ideally want the VM to boot only Windows. We'll be doing that by telling the Windows partition to
boot, ignoring the Linux boot menu, and then making a copy of that bootsector for the VM to use.
All that means we need two lines in the VMDK, as shown above: a line for the bootsector copy, starting at
sector 0 and stretching for 63 sectors; and the rest of the hard disk, starting at sector 63. And that means a
little calculation: the value in the VMDK for the size of the disk is 63 less than the actual disk.
Note that this is the value I've got in my VMDK, shown above.
I mentioned above that we'll be using a copy of the disk's bootsector for the VM, with Windows set to boot.
We'll need to set that up first:
(parted) quit
#
3 of 9 07/25/2007 11:25
Running a Windows Partition in VMware - Oopsilon http://oopsilon.com/Running-a-Windows-Partition-in-VMw
guestOS = "winxppro"
numvcpus = "1"
memsize = "128"
paevm = "FALSE"
sched.mem.pshare.enable = "TRUE"
MemAllowAutoScaleDown = "FALSE"
MemTrimRate = "-1"
nvram = "WindowsXP.nvram"
mks.enable3d = "FALSE"
vmmouse.present = "FALSE"
vmmouse.fileName = "auto detect"
tools.syncTime = "TRUE"
tools.remindinstall = "FALSE"
isolation.tools.hgfs.disable = "FALSE"
isolation.tools.dnd.disable = "FALSE"
isolation.tools.copy.enable = "TRUE"
isolation.tools.paste.enabled = "TRUE"
gui.restricted = "FALSE"
ethernet0.present = "TRUE"
ethernet0.connectionType = "nat"
ethernet0.addressType = "generated"
ethernet0.generatedAddress = "00:0c:29:59:aa:eb"
ethernet0.generatedAddressOffset = "0"
usb.present = "TRUE"
usb.generic.autoconnect = "TRUE"
sound.present = "TRUE"
sound.virtualdev = "sb16"
ide0:0.present = "TRUE"
ide0:0.fileName = "WindowsXP.vmdk"
ide0:0.mode = "independent-persistent"
ide0:0.deviceType = "rawDisk"
ide0:0.redo = ""
ide0:0.writeThrough = "FALSE"
ide0:0.startConnected = "TRUE"
ide1:0.present = "TRUE"
ide1:0.fileName = "/dev/cdrom"
ide1:0.deviceType = "atapi-cdrom"
ide1:0.writeThrough = "FALSE"
ide1:0.startConnected = "TRUE"
floppy0.present = "TRUE"
floppy0.fileName = "/dev/fd0"
floppy0.startConnected = "TRUE"
serial0.present = "FALSE"
serial1.present = "FALSE"
parallel0.present = "FALSE"
4 of 9 07/25/2007 11:25
Running a Windows Partition in VMware - Oopsilon http://oopsilon.com/Running-a-Windows-Partition-in-VMw
I've highlighted a couple of values which you might want to change: the location of the CD drive in the device
tree, and the amount of memory you want to allocate to the VM.
We can also take this opportunity to test that the Windows partition boots up immediately, without a boot menu
in the way. Reboot, and if the boot process doesn't run straight to Windows, you may need to tweak the
partition boot settings and recreate the bootsector copy.
Once you're booted into Windows, pull open the System properties (Control Panel -> System, or My Computer
(rightclick)-> Properties):
5 of 9 07/25/2007 11:25
Running a Windows Partition in VMware - Oopsilon http://oopsilon.com/Running-a-Windows-Partition-in-VMw
The default setup for this Hardware Profiles display is one profile, called "Default". Click on "Copy", to create a
new profile, and call that one "VMware", then move it to the top of the list with the arrow buttons. You can see
the settings I use in the image above, and we'll see exactly what that means for the Windows boot process in a
little while.
While you have the System Properties open, pull open the Driver Signing properties, and set the value of what
action Windows should take to "Ignore"; this allows any drivers to be installed automatically if devices are
picked up by Windows.
This is also a good time to set up a helper script, which will install the VMware Tools: a set of drivers for the
VMware emulated devices, and some services to help the Windows VM along. This could be done after the VM
is set up and running, but I had issues with that, as detailed later. I've decided to put it here in stage 3, to catch
the problem before it begins.
The VMware tools are provided by VMware as a CD ISO image, buried within the VMware Workstation
software. It's relatively easy to find: first of all, download Workstation from VMware, or any Linux mirror (I've
given a sample mirror below):
http://ftp.snt.utwente.nl/pub/os/linux/gentoo/distfiles/VMware-workstation-5.5.3-34685.tar.gz
Once you've got the file, extract its contents (you may need third-party tools to do this in Windows), and look
for a file called windows.iso; this is the Tools CD image. If you feel like wasting a CD, burn the image to one,
or you can mount the image as a drive using Daemon Tools or similar software.
When you can see the contents of the image, copy the files to your hard disk, in a directory called
C:\VMTools or something similar. Then dump the following into a .cmd file:
Also, put a small message (any you like) into ToolsHelperLock.txt in the same directory. The lock file will
be used by the helper script to work out if it needs to reboot. Once you've done this, add the script to your Start
Menu's Startup folder, and you'll be away.
Log yourself out of Windows and reboot; that should be the last time it needs to be started physically. Boot
yourself into Linux; it's time to test this thing.
6 of 9 07/25/2007 11:25
Running a Windows Partition in VMware - Oopsilon http://oopsilon.com/Running-a-Windows-Partition-in-VMw
Pick the VMware profile, and Windows should boot, into a very minimal VGA-colour mode: it doesn't have the
drivers for the "VMware SVGA" yet. At this point, the helper script should kick in, install the VMware tools, and
then reboot the VM. Make sure to remove the helper script from your Startup folder upon the next reboot; even
though it won't run, it'll still flash a Command-Prompt window up for a short while.
Initially, I set the VM's network card to a "bridged" type, allowing it to reside on the same network as the host
machine; this usually works fine. In the case of a laptop with wireless, however, it didn't so much: no
communication. After some experimentation, I resorted to the NAT method: one network that the host
computer sits on, and another between the host and VM. This also involves a bit of iptables trickery, so I'm
putting it in as a part of this guide.
In my case, the normal wireless network resides on 192.168.1.0/24, so I decided to put the virtual network
at 192.168.58.0/24. This means the host gets an address of 192.168.58.1 on the NAT network, and the
VM's network connection gets a static IP of 192.168.58.2; it also means the following changes to the Linux
host's configuration:
7 of 9 07/25/2007 11:25
Running a Windows Partition in VMware - Oopsilon http://oopsilon.com/Running-a-Windows-Partition-in-VMw
Note how the wireless interface ra0 has had a virtual interface added, dedicated to the transfer of traffic for the
virtual machine NAT. The particular configuration files you need to change may differ depending on the
distribution; the changes above are from my Gentoo system.
Let me know if you get it working, or if you want to shout at me about something.
8 of 9 07/25/2007 11:25
Running a Windows Partition in VMware - Oopsilon http://oopsilon.com/Running-a-Windows-Partition-in-VMw
9 of 9 07/25/2007 11:25