If you already have a Windows PC, you can install Linux and run your existing Windows configuration as a virtual machine. Jason Perlow explains how to do it.
For many Linux users, VMware has become an indispensable tool. While excellent emulation solutions, such as Wine and CrossOver Office can run selected mainstream Windows applications directly on top of Linux without virtualization or actual Windows code, only virtualization can provide perfect Windows compatibility. VMware makes the desktop computing experience complete.
However, virtual machine images of full operating system installs take up considerable hard drive space and consume more memory than emulation. And what’s hardest to swallow is having to re-install Windows (or the virtualized operating system of choice) and supplemental applications in the virtual machine. If you’ve been using a particular operating system instance for any length of time, chances are you have a legion of files, preferences, and software you want to keep. Moreover, you may not have your original install media, or you may prefer to retain a specific version of an application rather than upgrade. You may even want to dual-boot to your existing Windows install because it has games or other packages that donÕt work as well when virtualized.
Well, little did I know that the free, end-user VMware products — VMware Player and VMware Server — can run your existing, on-the-metal Windows configuration virtualized within Linux using a technology that’s really only known to users of VMware’s enterprise product, ESX Server, a part of their Virtual Infrastructure 3 suite. The technology, known as RAW Device Mapping (RDM), is a virtualized SCSI device compatibility mode that enables a virtual machine to boot from a physical disk (or partition) rather than a virtual disk file. This capability has been around for a long time, but VMware has never really advertised it, and hasn’t provided any wizard-like capability in VMware Player or Server to easily take advantage of it.
Here, I’m going to show you how to use it.
Creating a New Hardware Profile in Windows
Before you can virtualize your Windows XP system, add a new hardware profile so that when your existing Windows install boots up within VMware Player, its hardware profile isnÕt overwritten or corrupted by the newer, paravirtualized drivers. This way, you’ll still be able to use your existing Windows configuration on the metal if you have to.
To create a new hardware profile, boot your Windows XP system, open the Control Panel (Start Button > Settings > Control Panel), double click on System, and click on the Hardware tab. Next, click on Hardware Profiles, as depicted in Figure One. Copy the default profile to a new name, such as VMware.
FIGURE ONE: The System Properties Hardware Profile screen in the Windows XP Control Panel
Optionally, set the “Hardware Profiles Selection” to a timeout value you’re comfortable with (perhaps 30 seconds), or set it to “Wait until I select a hardware profile.” This setting controls the Hardware Profile selection screen when Windows XP first boots. By default, screen this doesn’t come up on most PCs, but since you’re adding a new hardware profile to the system, you’re going to get one from now on.
Remember, you never want to boot into your default profile during a virtualized session. Make sure you have enough time to select the VMware profile you just added.
Making Room On Your Disk for Linux
Presumably, you’ve got a PC that already dual-boots Linux and Windows, so if you do, you can skip this section entirely. If youÕve got a PC that runs Windows but doesnÕt have Linux installed, youÕre going to need to install Linux.
The easiest way to to proceed is buy a secondary hard disk, install it in your PC, and then install Linux on that new disk along with the GRUB boot loader to provide dual-boot capability. However, if you own a laptop, or have a huge hard drive with a lot of free space left, you might not be able to add a second hard disk or feel thereÕs no need to do so. In those instances, you must teclaim that unused hard drive space back to install Linux.
In the May 2007 “On The Desktop” column, I wrote about the System Rescue CD, a bootable, free CD distro designed specifically for system rescue and repair scenarios. Among the many tools you can use on that CD is ntfsresize, which enables you to reclaim unused disk sectors from a Windows NTFS filesystem and use it as free space in order to create a new partition.
Before you actually perform the resize, gather some important information. Boot with the System Rescue CD, and from the Linux bash prompt, issue the following command:
root@sysresccd /root% parted
You should get the following prompt:
GNU Parted 1.7.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted)
At the prompt, issue this command:
(parted) print free
Disk /dev/sda: 100GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
You should then get output similar to the following:
Number Start End Size Type File system Flags
32.3kB 32.9MB 32.9MB Free Space
2 32.9MB 52.9GB 52.8GB primary ntfs boot
3 52.9GB 100GB 47.1GB Free Space
Type "p" and then Enter to print out the partition table.
In this example, my NTFS partition, which is homed on a SATA drive, is enumerated as partition 2 (sda2 in Linux device parlance, or hda2 if it was an IDE disk) is 52.9 GB, residing on a 100 GB drive; the rest of my system is allocated as free space. On your system, youÕll have different results, depending on your drive size and the size of your partition.
If your machine is a Windows-only box, and the whole drive is allocated for NTFS, you’ll likely have a single sda1 partition taking up the entire disk, which looks something like this:
Number Start End Size Type File system Flags
1 32.3kB 100GB 100GB primary ntfs boot
Take note of this information, and then type q and Enter to exit parted.
Next, determine how much free space is left on that NTFS partition. Issue the following command from the SysRescCD prompt:
root@sysresccd /root% df -k /dev/sda2
Here, /dev/sda2 refers to the name of your NTFS partition Ñ it could just be /dev/sda1 or /dev/hda1 if your drive is all NTFS. On certain machines, such as Dell PCs and laptops, the first partition is used as a “utility” partition, in which case /dev/sda2 is the first operating system partition, as in the examples above. I’ve reclaimed my “utility” partition to minimize the number of primary partitions on the system, as you can only have four.)
You should get output similar to the following:
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda2 51608808 33021912 18586896 64% /media/sda2
In this example, my 53 GB disk is 64 percent utilized (33 GB in use) with 19 GB remaining.
To reclaim some of the unused space on NTFS as free space by re-sizing the partition, I would issue the following command:
root@sysresccd /root% ntfsresize /dev/sda2 -s 40G
In this example, I’ve specified the size of the new partition to be 40 GB. You can see ntfsresize in action in Figure Two. Make sure you leave enough free space left on the NTFS partition for Windows program data and swap . (It’s advantageous to boot into Windows before executing this command to offload some of your near-term storage to long term storage, such as burning your photos and MP3′s and other multimedia to DVDs and cleaning them off the drive.)
FIGURE TWO: ntfsresize in action on the SystemRescueCD
After performing a resize on your NTFS drive (or skipping it entirely if you’ve got enough free space on a local drive to install Linux), launch parted again at the console prompt and issue the following commands:
(parted) unit s
(parted) print
You should get output similar to the following:
Disk /dev/sda: 195371567s
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
2 64260s 103281884s 103217625s primary ntfs boot
1 103281885s 195366464s 92084580s extended
5 103281948s 107282069s 4000122s logical linux-swap
6 107282133s 107539109s 256977s logical ext3
7 107539173s 195366464s 87827292s logical ext3
Make a of the bolded value for total sectors on the disk. Write this number down, subtract 63, and write down the result. Next, issue the following two commands in parted:
(parted) unit cyl
(parted) print
You should get output similar to the following:
Disk /dev/sda: 12161cyl
Sector size (logical/physical): 512B/512B
BIOS cylinder,head,sector geometry: 12161,255,63. Each cylinder is
8225kB.
Partition Table: msdos
Number Start End Size Type File system Flags
2 4cyl 6428cyl 6425cyl primary ntfs boot
1 6429cyl 12160cyl 5732cyl extended
5 6429cyl 6677cyl 248cyl logical linux-swap
6 6678cyl 6693cyl 15cyl logical ext3
7 6694cyl 12160cyl 5466cyl logical ext3
Make a note of the values for cylinder, head, and sector geometry, respectively. Type a q at the parted prompt to exit.
Once you’ve re-sized your NTFS drive, reclaimed some disk space, and recorded your drive geometry values, go ahead and install your favorite Linux distribution on the free space.
Create and Customize the Virtual Machine Files
After installing Linux on your system, open a browser and download the vmdk and vmx files to your home directory. You can also download the files from http://www.linux-mag.com/download/2007-07/desktop/windows.vmdk and http://www.linux-mag.com/download/2007-07/desktop/windows.vmx.
Next, read in your hard disk’s master boot record (MBR) and export it to a file in your home directory. Issue the following command from a terminal prompt:
root@ubuntu-laptop:~# dd if=/dev/sda \
of=$HOME/windowsxp.mbr \
bs=512 count=63
You should get output like the following, as well as a file named windowsxp.mbr.
63+0 records in
63+0 records out
32256 bytes (32 kB) copied, 0.000809041 seconds, 39.9 MB/s
Next, open windows.vmdk file with a text editor and find this part of the file:
# Extent description
RW 63 FLAT "windowsxp.mbr" 0
RW 195371504 FLAT "/dev/sda" 63
# The Disk Data Base
#DDB
ddb.toolsVersion = "6530"
ddb.adapterType = "ide"
ddb.virtualHWVersion = "4"
ddb.geometry.sectors = "63"
ddb.geometry.heads = "255"
ddb.geometry.cylinders = "12161"
Edit the second RW line and the lines with sectors, heads, and cylinders, replacing the values in the file with the values you determined from the gparted session earlier. Save the file and exit.
Now you’re ready to run the windows.vmx file in VMware Player, VMware Server, or VMware Workstation. Choose “Windows” from the GRUB prompt, and then choose “VMware” from the Windows hardware profile menu. Figure Three shows Windows XP running virtualized from an RDM.
You can open up windows.vmx and tweak it to your desired settings, such as memory and virtual CPUs with the following fields:
numvcpus = "1"
memsize = "1024"
VMware Player can only support one virtual CPU. If you need more, use VMware Server, which is also a free download.
FIGURE 3: Windows XP, running virtualized from a raw device mapping
More About VMware
VMware has been covered extensively in prior issues of Linux Magazine. To learn how to install it on your system, please refer to “VMware Player“, “More Fun With VMware“, and “A Trio of Linux Tricks.”
Comments on "Run Your Windows With VMware"
Easier: Boot to Windows. Done.
“Easier: Boot to Windows. Done.”
Must be a native windows user. One that does not understand the importance of a virtual server in a corporate environment. The cost reduction factor that it brings to a small business.or the hundreds of other factors that make this technology so important.
“Easier: Use VMware or some type of virtual box.”
Of course you can also run Linux as a VM under Windows. Easy.
The thing that reeks here is the arrogance. If you want everyone to run Linux, stop treating them like a bunch of idiots. Look how many friends Bill’s arrogance has made him. Carry your superiority with dignity and grace, lest Linux becomes a target rather than a destination.
Its not about the host. Its about the technology that makes it possible.
What about restrictions on hardware changes that WinXP Service Pack 2 imposes? I was able to boot WinXP original from startup or in VMWare until that SP2 thing crawled in; forums tell that SP2 tolerates as much as three hardware changes before stalling startup (BSOD, in fact), but VMWare implies much more than those: RAM type, brand and amount; ethernet “card”, processor, disk(s), sound card, motherboard… And it simply doesn’t run.
Hey Chuck,
What did you find arrogant about this? That the author assumed he knew something that someone else didn’t and provided instructions? You’re just looking for something to bash, and of course you found it.
Is it possible to run Vista using this method ? Has anyone tried it ?
you either are this guy or just totally stole his work
http://www.advicesource.org/ubuntu/Run_Existing_Windows_Instalation_On_Ubuntu_With_Vmware_player.html
Hardware Profiles feature is not included in Vista:
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1193668&SiteID=1
However, under this article, it seems like there are some hardware profiles like capability:
http://www.lockergnome.com/nexus/windows/2006/12/05/hardware-profiles-in-vista/
Anyone got it working under Vista?
I encounter “GRUB GeoM Error” problem when openning the vmx file by VMware player.
Any guidance from anyone is appreciated.
“you either are this guy or just totally stole his work
http://www.advicesource.org/ubuntu/Run_Existing_Windows_Instalation_On_Ubuntu_With_Vmware_player.html “
First of all, let me say that while I did read the web page in question (I was in fact pointed towards it by our Editor In Chief as a potential topic for On The Desktop) I completely re-wrote the and clarified procedure so it would be more human understandable. And frankly, I had to add a lot more supporting text to turn it into an article.
Just like you can’t call a list of ingredients a unique copyrightable recipe you can’t call a list of OS commands “an article” or even unique work.
You said
‘Presumably, you’ve got a PC that already dual-boots Linux and Windows, so if you do, you can skip this section entirely’.
Then you say
‘Edit the second RW line and the lines with sectors, heads, and cylinders, replacing the values in the file with the values you determined from the gparted session earlier. Save the file and exit.
I already have a dual boot so can I skip that section or not?
Sean
You still need the drive geometry otherwise you can’t edit the files with the proper values.
Even though the article speaks of VMWare, is there any comparison with another VM?
OK, what’s the easiest way to get the drive geometry?
After grub and Windows selection I have a black screen with :
rootnoverify (hd0,2)
chainloader (hd0,0)+1
and vmplayer takes 100% of cpu.
Is there something misconfigured ?
Stephane
@Victor Gonzalez
I run Windows installs as well on linux using Xen.
Xen has no trouble at all running from normal block devices instead of sparse file like devices. Although I never tried to boot a bare metal windows install…
“Edit the second RW line and the lines with sectors, heads, and cylinders, replacing the values in the file with the values you determined from the gparted session earlier. Save the file and exit.”
Would you please clarify perhaps with examples?
Do you need to put in data for all drives, just the one containing the windows partition, or just the windows partition? Where do you get the “sectors” and “heads” information from the GNU parted output you posted? Also, where is the best place for those up us already set up to dual boot to obtain this data?
OK so the link posted above
http://www.advicesource.org/ubuntu/Run_Existing_Windows_Instalation_On_Ubuntu_With_Vmware_player.html
has much easier to follow instructions on editing the windows.vmdk file, but neither that link no the litany of Jason’s links at the end of this discuss how to actually get VM Server running. I made windows.vmx executable and tried running it as me, sudo and su – all with no luck. I just got a long list of “command not found” errors. I went to vmware’s site grabbed an RPM of VM server installed that with YaSt and tried again; same issue, I looked around for an icon to launch VMWare server nothing and I’ve seen no instructions anywhere for running it from the command line. What am I missing?
Chuck Gordon said “The thing that reeks here is the arrogance. If you want everyone to run Linux, stop treating them like a bunch of idiots. Look how many friends Bill’s arrogance has made him. Carry your superiority with dignity and grace, lest Linux becomes a target rather than a destination.”
Great quote Chuck. I really like that and you are right. Some of us, me included sometimes, are a little too arrogant. For this I apologize. Seriously. We, the converted, assume that we are the good guys and everyone should believe like us. Using VMWare to run Linux guests or Windows guests makes sense regardless of the Host OS. It is also a great way to try out another OS without totally committing to it. I have run VMWare both ways and frankly it depends mostly on what you need, have, and want that makes the biggest differences.
Anyway, I am sorry for my own arrogance in discussing Linux and I thank you for pointing it out. We need to be mindful of such things.
“you either are this guy or just totally stole his work
http://www.advicesource.org/ubuntu/Run_Existing_Windows_Instalation_On_Ubuntu_With_Vmware_player.html â€
While a bit harsh, the comment is not completely wrong, since you did not point to this page as a reference, but in a way claim originality by deliberately omitting to do so.
Most will figure out what to do when their (physical) disk is not PATA but SCSI or SATA but in your article, you should have included this piece of information. The orginal post does… along with some caveats that are also implicitely evident to a cautious user but stating them once more could never hurt.
Jason,
Unless I missed something, where do you put the vdmk , .vmx and .mbr files? Do I copy them into the root folder? I’m running Kubuntu 7.04 x64 on my laptop and I run VMWare server as root. This part of the instructions is vague. Please clarify. Thanks!
Best Regards,
Keith A. Lindsey, M.B.A.
Hi Keith,
I just made sure all the files where in the same directory and then I started vmplayer clicked on open existing machine and navigated to the folder and opened the .vmx file after this when you start vmplayer it gives you the option to open recent virtual machine, as vmplayer creates other files when it runs the virtual machine, using a dedicated directory maybe wise.
I had issues when NOT running as root so now I just open a terminal su and run vmplayer.
For information to anyone interested, my XP installation was refusing to boot, would just reboot and if I prevented reboot on serious error it would crash with boot_device_not_found error, I tried everything I knew and advice on the web, no luck. I was not too worried as I am a mainly Linux(PCLinuxOS 2007 for my desktop and laptop) user now and I could access all my files on the windows partition from linux, but my outlook pst file had some information I needed. Making the windows installation a virtual machine got everything working again including normal dual boot!
So perhaps following the advice in the article to setup your windows as a virtual machine is worth it just for when things go wrong in windows, not that this ever happens:-)
All the best
Ian
Thanks, Ian! That’s what I needed to know to get it to work perfectly!
Best Regards,
Keith A. Lindsey, M.B.A.
I was contemplating running Vista on top of Linux VMWare to improve performance. Vista runs like a dog so in VMWare on Linux the Linux OS should make the difference to a crazy OS like Vista. I will try it one day. VMWare isolates the problems of hardware inefficiences introduced. XP runs fast on a quadcore but Vista runs like a dog.
Only 2 Weeks into Linux (Ubuntu Hardy) so please be kind, clear and specific…
Did everything above and here is the message I get when I run the windows.vmx file:
——————————————–
| File not found: windows.vmdk |
| |
| This file is required to power on this |
| virtual machine. If this file was moved |
| please provide its new location. |
——————————————–
Even when I hit the ‘Browse’ button and navigate to the windows.vmdk file, it still complains. I have moved these files off my home directory to keep things organized but windows.vmx, windows.vmdk and windowsXP.mbr are all in the same place. Something simple I hope?
@Steve M
Dear Steve M, you managed to have your completely useless comment come up first and have thus exposed yourself to the rest of the world as a complete and utter dick for the rest of time.
I apologize myself for writing this comment because it is also useless but I am willing to be exposed as a dick in order to show what a complete and utter dick Steve M is and will forever be.
I’m new to vmware, is there a reverse-role how to, like running my second os(linux installation on second partition) in vmware on winxp, and still i can dual boot my computer
I run my linux distro on VirtualPC 2007 and it works great hardly takes up any of my ram or resorces.
Same goes for Innotek VirtualBox, like VirtualPC 2007, it works great and hardly takes up any of ram or resources. You can install VirtualBox on Windows, Linux, Mac OSX, and OpenSolaris hosts. Plus VirtualBox is free.
See Innotek VirtualBox for more information.
I run Vista and XP at the same time – in VirtualBox on Ubuntu. Why? Because I can. “Look Ma. No viri! No malignant software!”
I’ve got WinXP Pro on a SATA drive (/dev/sda), then I reclaimed an IDE drive and installed Ubuntu on it (/dev/sdb). I have vmware server installed, followed the above instructions to the letter, and it seems to be making an attempt at loading up windows, but grub stops with Error 17. In my infinite-number-of-monkeys troubleshooting way, I added a second disk (the Use a Physical Disk option) in case it needed the linux disk for one reason or another, but the error persisted (I have since removed it from the .vmx file because it didn’t help at all). Any suggestions would be appreciated – my google search wasn’t very fruitful.
awesome, i’ve been testing out ubuntu on my computer, completely wiping out windows all together and now i absolutely love linux. specifically ubuntu’s compiz fusion is by far the best windows 3D desktop management has never looked better, it makes aero look so 90′s.
linux might be a bit nerdy for most, but if u have the time and patience and really want to but your cards to work without gaming its in your best interest to use linux.
i was thinking of using VMware server to install windows vista, for gaming purposes but i heard it doesnt really work well for gaming, my best option would be to dual boot. i probably wont dual boot, just have to live without the games for now.
I think virtualbox is goot and aptable at ubuntu
see a tutorial at http://www.shibuvarkala.blogspot.com
I am using Windows XP, Windows Vista and Fedora, Knoppix in Vbox
Hi,
There are not so evident dependencies between the windows OS and the Linux OS. I have hit one. I installed Linux Linux Ubuntu 64 on a separated physical drive and I have another physical drive with Windows XP professional edition. Virtual Server would not run the windows OS because it not for the AMD64 CPU… Sure, it’s code written for intel. Then, how do I virtualize my windows from a 64 bits OS and a 64 bit Virtual Server ???
regards,
BT
jason.
Have you tried this with VirtualBox.?? If so.. why don’t you make an article too.
Thanks for the article and Kind Regards.
Luis
Anyone tried this with Windows 7? It lacks the \”Hardware Profiles\” thing, will I be running into trouble? I really don\’t know much about Windows, have been a Linux-only user for 6 years now, but I now need Windows for a few things at work. And sometimes I\’ll have to boot from it (but preferably not all the time). So, any tips?
I want to try this with 32bit Ubuntu 10.04 host and x64 Windows 7 guest. The linked vmdk and vmx cannot be found on the linux-mag website, the cited links are broken (the files are not any more on their original location also)!
Please fix that. I registered to linux-mag just right now to be able to get the files, but no luck.
Also, if anyone has some success, please help. I also tried VirtualBox but no luck yet with that either.
I just want to boot up my freakin’ Windows 7 partition into the VM, I didn’t think that this is such a magic thing…
Thank you for another excellent article. The place else could anyone get that kind of information in such a perfect way of writing? I’ve a presentation subsequent week, and I am on the look for such info.