LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Linux Answers > Applications / GUI / Multimedia
User Name
Password

Notices

By mariusm at 2006-08-30 11:39

OK, so you've bought a new PC and have Windows pre-installed. First, you shrank Windows partition to the minimum and installed your favorite Unix distribution. Then setup a dual boot to either operating systems and wondering if you really need to reboot to Windows each time you need to test how something looks on Windows or perhaps your girlfriend wants to do wicked stuff.

This page explains how to run Windows in Linux environment without a need to reboot or reinstalling Windows. The solution is to run VMware Player from raw Windows partition under Linux.

Everything on this page is pure hacking, even worse, not a single manual has been read. Everything you do falls under your responsibility and your own risk. You've been warned. Actually there's a good reason for VMware not to release manuals on vmx and vmdk formats: you should use their tools (VMware Workstation) to do such things and not poke around.

Here is a to-do list of this howto:

  1. Install VMware Player
  2. Create a Virtual Machine
  3. Create a Virtual Disk
  4. Decontaminate Hazardous Booting Options
  5. Prepare Windows for the Last Journey
  6. Boot It Up and Install VMware Tools

CAUTION: This howto contains many commands that can destroy the contents of your harddisk if misspelled, wrongly understood or just typed-in into wrong terminal.

I've done this twice on two separate Debian machines: with Windows 2000 Professional and Windows XP Home Edition. It worked, but one more warning: Windows XP asked for another key for product activation. I had to call special phone number (provided by Windows), talk to a Microsoft guy and exchange some numbers to activate Windows XP on "new hardware" provided by VMware Player. After re-activation the normal boot back to the old hardware discards the activation and ... don't know, haven't been that far. If you don't reactivate and come back to virtual solution, Windows reactivates itself without additional numbers.

Installing VMware Player in Linux

This is supposed to be easy, if not, don't bother going any further.
VMware Player instructions are here http://www.vmware.com/download/player/. You will probably want to get a .deb file instead of rpm, but don't bother, the solution with alien did not work out for me, so save time and install from tar.gz. Then run vmware-config.pl to setup kernel module, guest network, etc.. If you are not sure what type of network you want, choose defaults, NAT (Network Address Translation) should hide your Windows-sins from the rest of the world.

If you have custom kernel, VMware Player may require sources or at least headers of your kernel. So make sure you install your proper linux-headers-X.Y.Z before installing the kernel image linux-image-X.Y.Z, this will make sure that proper links to headers are created and vmware-config.pl can easily find them.

By default VMware Player uses Control+Alt key combination to jump out of the guest. Then Control+Alt+Delete is accessible via Control+Alt+Insert. If you also find this annoying you can change the jumping out shortcut to Control+Alt+Shift by adding the following lines to your ~/.vmware/preferences:

pref.hotkey.shift = "true"
pref.hotkey.control = "true"
pref.hotkey.alt = "true"

This key combination is especially useful when running Linux guests.

Creating a Virtual Machine

You might want to use this javascript vmx builder: http://www.consolevision.com/members/dcgrendel/vmxform.html to get the initial version and come back here for disk options. Here we go with windows.vmx, the lines starting with # are comments:

#!/opt/local/bin/vmplayer
config.version = "8"
virtualHW.version = "4"
MemAllowAutoScaleDown = "TRUE"
MemTrimRate = "-1"
uuid.location = "56 4d aa ca 7f f2 08 05-5b 60 2c 15 00 a8 58 db"
uuid.bios = "56 4d aa ca 7f f2 08 05-5b 60 2c 15 00 a8 58 db"
uuid.action = "/questions/create"
checkpoint.vmState = ""
#
# Here the interesting stuff begins:
# the title of vmplayer window when running this machine:
displayName = "Windblows"
# prepare for WindowsXPHome, also see http://sanbarrow.com/vmx-guestos.html
guestOS = "winxphome"
# allocate 384M of RAM for your guest
memsize = "384"
# networking stuff, please change the last three numbers of generatedAddress
ethernet0.present = "TRUE"
ethernet0.connectionType = "nat"
ethernet0.addressType = "generated"
ethernet0.generatedAddress = "00:0c:29:a8:58:db"
ethernet0.generatedAddressOffset = "0"
#
usb.present = "TRUE"
usb.generic.autoconnect = "FALSE"
usb.startConnected = "FALSE"
# we may want to have sound:
sound.present = "TRUE"
sound.autodetect = "TRUE"
sound.startConnected = "FALSE"
# es1371 is good for PCI, you can also try sb16, or remove completely
sound.virtualDev = "es1371"
sound.fileName = "-1"
# no SCSI devices this time..
scsi0.present = "FALSE"
scsi0:0.present = "FALSE"
scsi0:1.present = "FALSE"
#
# Here I connect my Windows 98 boot floppy to to get rid of grub in MBR:
floppy0.present = "FALSE"
floppy0.fileName = "bootWin98SE.img"
floppy0.filetype = "file"
floppy0.startConnected = "FALSE"
#
# This is the important part about our disk with everything on it:
ide0:0.present = "TRUE"
ide0:0.fileName = "rawdisk.vmdk"
ide0:0.mode = "independent-persistent"
ide0:0.deviceType = "rawDisk"
ide0:0.writeThrough = "FALSE"
ide0:0.startConnected = "TRUE"
ide0:0.redo = ""
#
ide0:1.present = "FALSE"
#
# I connected my /dev/hdb DVD-ROM as secondary master IDE:
ide1:0.present = "TRUE"
ide1:0.deviceType = "atapi-cdrom"
ide1:0.filename = "/dev/hdb"
ide1:0.startConnected = "FALSE"
ide1:1.present = "FALSE"
#
# synchronize the time of guest with host system clock:
tools.syncTime = "TRUE"
tools.remindInstall = "FALSE"

Creating a Virtual Disk

This is the most complicated part, and the most dangerous.

Never ever boot from the same (root) partition twice at the same time. This will almost definetly result in tragic loss of data. You might not even be able to boot after that! So before you see your boot menu in VMware Player, take care and remove the automatic boot selection and timeout features.

In order to operate on raw harddisk you will need to give user permissions to access the /dev/hd* files. Those files usually belong to disk group in Debian, so add your user to this group while being root: adduser johndoe disk. You will have to logout-login for the new group to take effect.

First I found how to plug the whole physical disk into VMware Player machine, it's simple but is very dangerous. So go to the next method if you can.

Plain Physical Disk -- Dangerous

I assume that you have Windows and Linux installed on the same physical hard disk, but on different partitions. The boot manager is installed in the Master Boot Record (MBR) of the disk.

First, remove the timeout feature from your boot manager. In grub it is done by commenting out the line with "timeout 30" in /boot/grub/menu.lst file. If you use other than grub, please consult the documentation, it is crucial that the bootloader won't boot the default partition, you should be able to change it and there should not be any rush. You will almost definetly loose the data and might not even boot again if you boot the same partition twice. Here is the example of virtual disk file:

# Disk DescriptorFile
version=1
CID=f7e370a1
parentCID=ffffffff
createType="fullDevice"
#
# The number 78140160 is the size of my whole disk in 512B sectors
# consult "sfdisk -d /dev/hda" if not sure.
# If vmplayer complains, look at vmware.log for the "facts"
# Extent description
# length type file offset
RW 78140160 FLAT "/dev/hda" 0
#
# The Disk Data Base
#DDB
#
# This geometry should work for almost all drives.
# If wmplayer complains, again, look at vmware.log for "facts"
ddb.virtualHWVersion = "4"
ddb.geometry.cylinders = "16383"
ddb.geometry.heads = "16"
ddb.geometry.sectors = "63"
ddb.geometry.biosCylinders = "1024"
ddb.geometry.biosHeads = "255"
ddb.geometry.biosSectors = "63"
ddb.adapterType = "ide"
ddb.toolsVersion = "6404"

Generic Boot Manager Separation

OK, so now we want to avoid accidental select of Linux partition upon VMware Player boot. The trick is to use different Master Boot Record (MBR) where the boot manager sits. But on the other hand we still want to use the same physical partitions where Windows sit.

This is probably the only safe way to go if you have extended partitions (I could not find configuration of partitionedDevice with extended partitions).

First, save a copy of your /dev/hda disk MBR to a file mbr.img: dd if=/dev/hda of=mbr.img bs=512 count=63. OK, I admit that boot manager sits in the first 446 bytes (the next 56 bytes contain partitioning information, so don't harm it), but for VMware Player you need 63 sectors, for some reason, like here: http://www.davidlaporte.org/tutorials/ghostinthemachine.php. Then create the disk descriptor file, here is an example:

# Disk DescriptorFile
version=1
CID=a15a2810
parentCID=ffffffff
createType="monolithicFlat"
#
# The idea is the similar:
# 1st line means the first 63 sectors are in "FLAT" file mbr.img starting from 0
# 2nd line means the following 78140097=78140160-63 of /dev/hda file from pos.63
# Extent description
# length type file offset
RW 63 FLAT "mbr.img" 0
RW 78140097 FLAT "/dev/hda" 63
#
# The Disk Data Base
#DDB
# The same as in previous example:
ddb.virtualHWVersion = "4"
ddb.geometry.cylinders = "16383"
ddb.geometry.heads = "16"
ddb.geometry.sectors = "63"
ddb.geometry.biosCylinders = "1024"
ddb.geometry.biosHeads = "255"
ddb.geometry.biosSectors = "63"
ddb.adapterType = "ide"
ddb.toolsVersion = "6404"

Now that you have separated MBR from physical disk into file you can overwrite your virtual MBR. I used Windows 98 boot floppy to run "fdisk /mbr" and wipe grub from virtual MBR and install default boot loader witch gives control to the first bootable partition (Windows). The other solution could be (I haven't tried) boot VMware Player from Linux Live CD and erase the first 446 bytes: dd if=/dev/zero of=/dev/hda bs=446 count=1.

If VMware Player starts complaining about new disk in virtual machine and asks to remove and add it again, then something went wrong with virtual BIOS information. In this case I just remove nvram file (rm nvram) and retry.

Disk as Partitioned Device

If you don't have extended partitions, then you can gain more control and specify disk as a set of partitions, where some of them (e.g. Linux) can be hidden (from Windows).

First, save a copy of your /dev/hda disk MBR to a file mbr.img: dd if=/dev/hda of=mbr.img bs=512 count=63. Then create the disk descriptor file by following the example:

# Disk DescriptorFile
version=1
CID=46956dfd
parentCID=ffffffff
createType="partitionedDevice"
#
# Extent description
# length type file offset
RW 63 FLAT "mbr.img" 0
RW 20980827 FLAT "/dev/hda" 63
RW 55086885 ZERO
RW 1044225 FLAT "/dev/hda" 76067775
RW 1044225 ZERO
# the structure above reflects the output of sfdisk -d /dev/hda:
#(mbr.img : start= 0, size= 63)
#/dev/hda1 : start= 63, size= 20980827, Id= 7, bootable
#/dev/hda2 : start= 20980890, size= 55086885, Id=83
#/dev/hda3 : start= 76067775, size= 1044225, Id= e
#/dev/hda4 : start= 77112000, size= 1044225, Id=82
#My Windows live in hda1 and hda3.
#Put ZERO to hide hda2 and hda4 (Linux) partitions (prevent Windows even seeing #them!).
#Notice that VMware Player does not accept devices like /dev/hda1.
#
# The Disk Data Base
#DDB
#
ddb.toolsVersion = "6404"
ddb.adapterType = "ide"
ddb.geometry.biosSectors = "63"
ddb.geometry.biosHeads = "255"
ddb.geometry.biosCylinders = "1024"
ddb.geometry.sectors = "63"
ddb.geometry.heads = "16"
ddb.geometry.cylinders = "16383"
ddb.virtualHWVersion = "4"

Use the procedure above to get rid of grub from virtual MBR.

Prepare Windows

This is probably your last Windows boot with real hardware.

In order to tell Windows that you are going to run on different (i.e. virtual) hardware, you need to create a separate software and hardware profile for each hardware setup.

Sadly I don't know such thing as "software profile" in Windows. We will have to get rid of auto-startups of all sorts of system utilities, which might get in the way while running in VMware Player. You should examine your start menu (Start-Program Files-Startup) and remove everything that is your hardware specific (they won't work anyway), this includes laptop fan, CPU frequency control, multimedia button support, special video utilities running in system tray, wireless network setup utilities etc.. Also cleanup the registry:

  1. Launch the registry editor: Start-Run-Open: regedit
  2. Backup the registry by clicking on the top most node ("My Computer"),
    choose File-Export, type in some meaningfull name, such as
    reg2006-08-26
  3. Goto
    HKEY_CURRENT_USER/Software/Microsoft/Windows/CurrentVersion/Run
    and see what programs are started. You might discover a virus or two
    sitting already there. Cleanup as you did with your "Startup", you
    should keep the anti-virus if you have one
  4. Goto
    HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run
    and cleanup there as in previous step. You want to come back here more
    often to remove other weird stuff like RealPlayer/AcrobatReader "quick
    startup".

Here are the steps to create a hardware profile for VMware Player:

  1. Right-click on "My Computer" icon, choose "Properties".
  2. Choose "Hardware" tab in "System Properties".
  3. Click "Hardware Profiles" button.
  4. Click "Copy" button, this should create one more profile (usually
    there is only one profile, unless you use docking station..).
  5. Click on "... (Current)" profile, click "Rename" button and rename
    it to e.g. "vmware".
  6. Click "OK"..."OK" until you close all windows except "System
    properties".
  7. Click "Device Manager" button
  8. Disable all your network adapters, display adapters, sound drivers
    (except "Legacy" and don't touch codecs, only drivers!) and any exotic
    non-generic devices you might have, like TVcard. The network, sound
    and especially display adapter drivers will be provided by VMware
    tools.

Now I am assuming that you will run the "vmware" profile that is going to be dedicated to VMware Player virtual hardware. Say good-bye and reboot back to Linux now.

Booting it Up in VMware Player

Now you work in Linux. Launch VMware Player with vmplayer windows.vmx. If not successful look at vmware.log and try googling for the solution, http://sanbarrow.com/ has plenty of advices. Typical problems are wrong disk configurations. Sometimes deleting nvram helps.

If Windows finally got up and running, it will find plenty of new hardware, but you must cancel all the driver setup until VMware Tools are installed. Don't even click on a System Tray balloon asking to change Display adapter resolution or whatever, this might result in blue screen of death. You only need network card for now, perhaps Windows will find some default (AMD?) drivers for your virtual network card.

My Windows XP Home Edition required a new product activation when I first logged in. Not sure if it's because of infamous Windows Genuine Advantage program, but Windows 2000 Professional still works without any call-home or sentiments to real hardware. The product re-activation looked like the following: Windows rejects the old key, then the other choice in the dialog is to call a local Microsoft representative, luckily that was charge-free number, dialog displays the long installation number and asks for activation number which is dictated via phone. Eventually click finish and it's done. Except that you might not be able to run Windows on a real hardware anymore since it will need product re-activation (in 3 days) again.

Installing VMware Tools in Windows

VMware Tools are optional, but they provide drivers for display adapter (to run in higher than 640x480 resolution) and greatly improve the interaction with virtual machine, so it's highly recommended. Here are the steps from http://www.brandonhutchinson.com/Installing_VMware_Tools_with_VMware_Player.html:

  1. Get the VMware Workstation from http://www.vmware.com/download/ws/,
    e.g.
    wget http://download3.vmware.com/software/wkst/VMware-workstation-5.5.0-18463.tar.gz
  2. Locate windows.iso:
    tar ztvf VMware-workstation-5.5.0-18463.tar.gz | grep windows.iso
  3. Extract windows.iso:
    tar zxvf VMware-workstation-5.5.0-18463.tar.gz vmware-distrib/lib/isoimages/windows.iso
  4. (you can also find VMware Tools for Linux guests too: look for
    linux.iso)
  5. Mount windows.iso as loopback device, i.e. with root:
    mkdir /mnt/vmware-tools ; mount -o loop windows.iso /mnt/vmware-tools
  6. Archive the tools:
    cd /mnt ; zip -r ~/vmware-tools.zip vmware-tools
  7. Transfer vmware-tools.zip to windows. I used pscp.exe to transfer
    via ssh from Linux host (look for Linux host IP with
    ifconfig). Alternatively you can setup samba directory share on your
    Linux (this is easy, just three lines in /etc/samba/smb.conf) and get the files via "Network Neighborhood". It seems that
    VMware "Shared Folders" feature does not work in VMware Player, and besides
    it needs VMware Tools already installed.
  8. Unzip and install by running setup.exe.
  9. After installation Windows will need restarting (as always)...

That's it, have fun!


by musicman_ace on Wed, 2006-08-30 23:09
VMware server is free and has more virtual network support features

by mariusm on Fri, 2006-09-01 03:23
Quote:
Originally Posted by musicman_ace
VMware server is free and has more virtual network support features
hm.. yes that's true, VMware Server can do most of the things in friendly fashion. But I still have problems with extended partitions: VMware complains about the disk configuration it tries to create, it says remove the disk and put it back again. Perhaps it's a vmware bug.
And besides, vmware-server still requires registration (serial number) for some reason :-/

by mariusm on Fri, 2006-09-01 03:24
------------------------------------------------------

by ninevoltz on Sun, 2006-11-05 13:44
Anyone have a howto to accomplish the opposite, boot a Linux physical disk/partition in VMWare from Windows?

by atessier on Sun, 2006-12-31 08:36
Hi,

First thank you for a great article, it solved all my problems.

I just wanted to point out that once you have windows.iso on your linux box, instead of going through step 5 6 and 7 to copy the iso in the windows VM, you could edit your vmx file to point to the windows.iso. You need to replace this line :

ide1:0.filename = "windows.iso"

make sure the windows.iso file is in the same directory of your wmx file.
Boot your windows VM and open up "My computer" you should see your cd-rom "VMware Tools ( D: )" Double click on this icon and it will launch the setup.

There you go.

André Tessier

by ludwig on Tue, 2007-01-02 00:15
Linux is my primary OS. For years I've used a dual-boot system, with Win2000 and Debian. I just recently installed vmware server on my linux system, and now I'm running Win2000 in linux with minimal effort! Now I rarely find any reason to reboot at all. From what I've read on this post, running vmware server is MUCH easier than dealing with vmware player, although you have to have the Windows installation media at hand.

by mariusm on Thu, 2007-01-25 06:59
Quote:
Originally Posted by ninevoltz
Anyone have a howto to accomplish the opposite, boot a Linux physical disk/partition in VMWare from Windows?
just look for example here, how I tried to install SP1 for Visual Studio 2005:
http://www.cs.aau.dk/~marius/bajeria...rikes_back.png

Do you understand what proprietary OS can do to you?

You simply don't want to run anything on Windows, not even VMware, trust me.

by djtm on Fri, 2007-05-11 13:29
Great!
Thanks a lot, wanted to do this for a while already!

by PB0711 on Sat, 2008-06-07 17:59
seriously rocks. One thing thou the link under creating a virtual machine doesn't work anymore . But I guess I can just copy and paste the files.
One thing which would be a nice update is to have explaination for multiple hard drives and for sda instead of hda. If it all works i'll post my updates
Once this is up and working I think I might reach computing heaven

by Criminal Bizzy on Mon, 2012-02-13 10:28
I am looking into creating a virtual Windows machine on Linux. So far the only real choices that I have are KVM, Virtualbox OSE, or this VMware hack that you have posted. My question to you is how flexible is this method to multiple distributions? Have you tried this on more than one distro with the same partition or do I have to go through this again every time I decide to change my distro?


  



All times are GMT -5. The time now is 07:59 AM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration