Looking to run Linux on your computer but preserve the current Windows installation as a virtual machine? Trying to virtualize a Windows installation so you can transfer it to another computer?
Using these steps you are likely to be able to take your existing physical Windows partition and convert it into a working virtual machine. I did this with a Windows 7 physical image then installing Fedora 23 and using VirtualBox to run Windows 7.
Amazingly, to me at least, the process of creating the virtual disk image is performed from the running Windows system you'd like to virtualize. This is really convenient and much nicer than having to reinstall from scratch. disk2vhd is what enables you to do this on-the-fly virtual disk creation. It is created by Microsoft, so its kind of funny to use their tool to make it easy to convert a computer to Linux.
NOTE - This level of monkeying around with operating systems and file systems does not always end well. You should back up all of your data before starting, because if something goes wrong you'll likely end up reinstalling from scratch into a virtual machine and wanting to copy your data back after that process is complete.
This guide on lifeofageekadmin.com provided some helpful steps that I used when figuring out how to do this.
Using these steps you are likely to be able to take your existing physical Windows partition and convert it into a working virtual machine. I did this with a Windows 7 physical image then installing Fedora 23 and using VirtualBox to run Windows 7.
NOTE - This level of monkeying around with operating systems and file systems does not always end well. You should back up all of your data before starting, because if something goes wrong you'll likely end up reinstalling from scratch into a virtual machine and wanting to copy your data back after that process is complete.
The overall process:
- Create a virtual machine disk file of the physical Windows system.
- Store that virtual machine disk file on an external storage device temporarily
- Confirm that everything appears to have worked.
- Install Linux (this overwrites the physical Windows system)
- Copy back the virtual machine disk file and create a virtual machine from it
- Enjoy your new Linux system and the convenience of running Windows in a VM when you need it.
Step-by-step:
- Get a large external storage device to put the virtual machine image on. The storage should be at least as large as the one inside of your computer if you want to ensure you won't run out of space. I used a 1+TB external usb disk drive.
- Download disk2vhd from http://technet.microsoft.com/en-us/sysinternals/ee656415
- Run disk2vhd. Ensure that you've unchecked 'vhdx' unless you know that your virtualization software can support it. I don't think virtualbox can, so I unchecked that box.
- Wait for some time until the image is created. It took an hour or more in my case.
- NOTE: disk2vhd will also create an image of the external USB storage that is being used to hold the primary drive image (the one with the Windows install). You may see '<computername>-0.vhd' and '<computername>-1.vhd'. The '-1.vhd' file was the one created of the backup storage. I only removed it at the very end though, because I wasn't sure at the time.
- At this point you may notice that the virtual disk file is smaller than your physical disk. Mine was 100GB vs. the 256GB SDD that it came from, and appears to reflect only the amount of data that was present.
- Download and install VirtualBox.
- Create a virtual machine and point it at the '<computername>-0.vhd' file on the usb storage.
- Start up the virtual machine to test that the disk2vhd process was successful.
- At this point I ran into a BSOD
- And used these steps to resolve it by switching the storage controller to an IDE one.
- At this point the virtual machine started and booted the virtual disk copy of my physical install. All of my applications were present as were all of my files. This let me confirm that the disk image looked good.
- Power everything down and unplug the usb storage.
- Install Linux. (NOTE: Once you've reformatted the Windows partition you can't go back)
- Install VirtualBox
- Plug in your external storage
- NOTE: At this point I made a copy of the .vhd file just in case I broke something. I ended up not needing it but I thought it was a good idea and worth the hour or so it took to copy the 100GB to another file on the usb storage.
- Create a new virtual machine, point it at the usb storage .vhd file
- Boot the Windows VM up (See the above step about the storage controller if you get a BSOD). At this point everything worked well for me and Windows started up normally.
- Install guest tools
- Enjoy, you've successfully transferred a physical Windows install to a virtual machine!
- To transfer the VM back to your internal storage:
- Power off the virtual machine
- Use VirtualBox virtual media manager to clone the virtual disk to a location on your internal hdd. At this point I also converted the file to a .vdi, the native VirtualBox format.
- Modify the virtual machine settings to point at this .vdi file.
This guide on lifeofageekadmin.com provided some helpful steps that I used when figuring out how to do this.
Comments
Post a Comment