head_parBC

Converting/cloning a Parallels VM to Boot Camp on Mac

A good friend of mine, Christopher Brown (@ccbrown11), has successfully converted a Windows 7 virtual machine for Parallels on Mac OS X into a full-fledged Boot Camp partition on a Mac computer. Much thanks goes to Chris for his work, and he’s even written up a nice guide on how to recreate his process. If you are interested, check out his guide below!


Overview

This guide will explain the process of taking a Parallels virtual machine running Windows 7 and turning it into a native Boot Camp partition on a Mac. After replacing my MacBook’s internal optical drive with a solid state drive, the typical process of installing a Boot Camp OS wouldn’t work. Therefore I developed this method, and cloned a fresh Windows 7 VM to my Boot Camp partition.

Who should use this?

This method isn’t something you should use if you don’t know your way around a computer. Even if you do know your way around a computer, I can’t imagine this method being the best way to go for very many people at all. For myself, it would have been much easier and much less time consuming to simply put the optical drive back into my MacBook and install Windows the normal way. However, I decided I really didn’t want to open my MacBook and I kind of have a thing for doing things the hard way (especially if I can learn something from it). Even if you have a lot of documents and programs on your Windows VM, it would probably be easier to do a fresh install, then transfer those individually. That said, this certainly was an interesting project and you may learn something from it or find it useful to help meet your own unique goals. Basically, if you’re thinking about doing this, read over the entire guide first. If you don’t understand it entirely, don’t do this. Otherwise, you can decide for yourself.

Let me also note that this is not a polished method. I have done it exactly once. I’m confident that the method works, but some steps could certainly be made easier.

Process Outline

These are the basic steps required to get the job done:

  1. Create the Boot Camp partition and make it bootable.
  2. Copy the source vm’s filesystem to the boot camp partition.
  3. Fix the Boot Camp partition’s mount devices and boot manager.
  4. Fix the Boot Camp partition’s storage controller drivers and registry values.
  5. Profit!

Prerequisites

  • A Mac computer of course.
  • Parallels Desktop (I’m using Parallels Desktop 7 for this.)
  • The Windows 7 virtual machine which is to be cloned to the Boot Camp partition. This will be referred to as the “source VM”.
  • A second Windows 7 virtual machine which you’ll use to manipulate the source VM and the Boot Camp partition. This will be referred to as the “transfer VM”.
  • A Windows 7 install disk.
  • Either a Mac OS X install disk or a second Mac that can be connected via a Firewire cable.
  • A USB flash drive (of any size).

The Guide

1. Create the Boot Camp partition and make it bootable.

Use the Boot Camp Assistant to create a second partition on your disk.

Create a VM that uses the Boot Camp disk as its only disk. This will be referred to as the “Boot Camp VM”. Mount the Windows 7 install disk on this VM and go through the normal installation process. The installation is expected to fail because for security reasons Parallels won’t let the VM write to particular areas of the disk such as the MBR and GPT. Once the installer tells you it’s failed, turn off the virtual machine. Now find your Boot Camp VM on disk (the .pvm bundle), right click it and hit “Show Package Contents”. You should see some .hdd files. One of these represents the disk with your boot camp partition on it. The name of it will be something like “ST9500420ASG (disk1).hdd”. Right click it and hit “Show Package Contents”. Copy the file named “PhysicalMbr.hds” to your flash drive.

Now you will need to overwrite your disk’s MBR with the contents of this file. Be extremely careful during this step. Either boot your Mac using a Mac OS X install disk or boot it into Firewire disk mode (hold T when you start it up) and connect it to another Mac. Using the Disk Utility, figure out what your Boot Camp partition’s disk identifier is. Select the disk that the partition is on (don’t select the partition itself) and hit the Info button. The disk identifier is clearly labeled and looks something like this: “disk1″. Make a note of this. Unmount all of the partitions that are on this disk. Open up Terminal and use the following command to overwrite your disk’s MBR:

dd if=/Volumes/FlashDrive/PhysicalMbr.hds of=/dev/disk1 bs=512 count=1

Replace “/Volumes/FlashDrive/PhysicalMbr.hds” with the actual path of the PhysicalMbr.hds file that you put on your flash drive, and replace “disk1″ with the disk identifier you noted earlier.

Boot Mac OS X up again. Install rEFIt (http://refit.sourceforge.net). Restart the Mac, holding the alt key to get to the os selection menu. One of the options should be rEFIt. Using Lion, I had to restart a couple of times until rEFIt showed up. Once it does, select it, then you should see the Windows partition in the rEFIt menu. Select the Windows partition. At this point, you should expect to get a “BOOTMGR IS MISSING” error. That’s fine. We only do this because rEFIt seems to do something here that makes the Windows partition show up in Apple’s OS selection menu. Boot into OS X again and uninstall rEFIt (delete the /efi and Library/StartupItems/rEFItBlesser folders).

SELF-CHECK: When you turn on your Mac, holding the alt key, you reach an OS selection menu that shows both your Mac partition and your Windows partition. When you select the Windows partition you get a “BOOTMGR IS MISSING” error.

2. Copy the source VM’s filesystem to the boot camp partition.

First, configure your source VM to have the Boot Camp partition connected. Start up the source VM and make a note of the drive letter it assigns to the Boot Camp partition. Then shut down the source VM. We’ll reference this drive letter later.

Configure the transfer VM to have a total of 3 disks: its boot disk, the source vm’s disk, and the Boot Camp partition. Boot up the transfer VM. Do a quick NTFS format of the Boot Camp partition to clean it up (ignore the Parallels security error). Then run the following command to copy all of the files from the source VM to the Boot Camp partition. Replace G with the drive letter of the source VM and H with the drive letter of the Boot Camp partition.

robocopy G:\ H:\ /mir /copyall /xj /b /r:3 /w:2

This copies everything except for junctions to the Boot Camp partition. We’ll have to do that manually later.

The source VM probably has a second 100MB partition used for the boot manager. This contains files necessary for booting the machine. Use the following to copy them to the Boot Camp partition. Replace E with the drive letter of the source VM’s boot partition and H with the drive letter of the Boot Camp partition.

robocopy E:\ H:\ /mir /copyall /xj /b /r:3 /w:2

Now the Boot Camp partition should have all of the source vm’s files as well as the boot manager.

Now we need to rebuild the junctions that weren’t copied. Using a program like Junction Link Magic (http://www.rekenwonder.com/linkmagic.htm), you’ll have to type out a list of junctions that existed on the source VM and form a series of mklink commands. This will be tedious and there’s probably a better way, but I figured it’d likely take longer to find that better way than to just type them out (there were only about 40). I was also able to speed up the process some by taking screenshots of the window and using an online OCR tool to convert it to text. You should end up with a file that looks like this:

mklink /j "H:\Documents and Settings" "C:\Users"
mklink /j "H:\ProgramData\Application Data" "C:\ProgramData"
mklink /j "H:\ProgramData\Desktop" "C:\Users\Public\Desktop"
mklink /j "H:\ProgramData\Documents" "C:\Users\Public\Documents"
mklink /j "H:\ProgramData\Favorites" "C:\Users\Public\Favorites"
mklink /j "H:\ProgramData\Start Menu" "C:\ProgramData\Microsoft\Windows\Start Menu"
mklink /j "H:\ProgramData\Templates" "C:\ProgramData\Microsoft\Windows\Templates"
mklink /d "H:\Users\All Users" "C:\ProgramData"
mklink /j "H:\Users\Admin\AppData\Local\Application Data" "C:\Users\Admin\AppData\Local"
mklink /j "H:\Users\Admin\AppData\Local\History" "C:\Users\Admin\AppData\Local\Microsoft\Windows\History"
mklink /j "H:\Users\Admin\AppData\Local\Temporary Internet Files" "C:\Users\Admin\AppData\Local\Microsoft\Windows\Temporary Internet Files"
mklink /j "H:\Users\Admin\Application Data" "C:\Users\Admin\AppData\Roaming"
mklink /j "H:\Users\Admin\Cookies" "C:\Users\Admin\AppData\Roaming\Microsoft\Windows\Cookies"
mklink /j "H:\Users\Admin\Documents\My Music" "C:\Users\Admin\Music"
mklink /j "H:\Users\Admin\Documents\My Pictures" "C:\Users\Admin\Pictures"
mklink /j "H:\Users\Admin\Documents\My Videos" "C:\Users\Admin\Videos"
mklink /j "H:\Users\Admin\Local Settings" "C:\Users\Admin\AppData\Local"
mklink /j "H:\Users\Admin\My Documents" "C:\Users\Admin\Documents"
mklink /j "H:\Users\Admin\NetHood" "C:\Users\Admin\AppData\Roaming\Microsoft\Windows\Network Shortcuts"
mklink /j "H:\Users\Admin\PrintHood" "C:\Users\Admin\AppData\Roaming\Microsoft\Windows\Printer Shortcuts"
mklink /j "H:\Users\Admin\Recent" "C:\Users\Admin\AppData\Roaming\Microsoft\Windows\Recent"
mklink /j "H:\Users\Admin\SendTo" "C:\Users\Admin\AppData\Roaming\Microsoft\Windows\SendTo"
mklink /j "H:\Users\Admin\Start Menu" "C:\Users\Admin\AppData\Roaming\Microsoft\Windows\Start Menu"
mklink /j "H:\Users\Admin\Templates" "C:\Users\Admin\AppData\Roaming\Microsoft\Windows\Templates"
mklink /j "H:\Users\Default\AppData\Local\Application Data" "C:\Users\Default\AppData\Local"
mklink /j "H:\Users\Default\AppData\Local\History" "C:\Users\Default\AppData\Local\Microsoft\Windows\History"
mklink /j "H:\Users\Default\AppData\Local\Temporary Internet Files" "C:\Users\Default\AppData\Local\Microsoft\Windows\Temporary Internet Files"
mklink /j "H:\Users\Default\Application Data" "C:\Users\Default\AppData\Roaming"
mklink /j "H:\Users\Default\Cookies" "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Cookies"
mklink /j "H:\Users\Default\Documents\My Music" "C:\Users\Default\Music"
mklink /j "H:\Users\Default\Documents\My Pictures" "C:\Users\Default\Pictures"
mklink /j "H:\Users\Default\Documents\My Videos" "C:\Users\Default\Videos"
mklink /j "H:\Users\Default\Local Settings" "C:\Users\Default\AppData\Local"
mklink /j "H:\Users\Default\My Documents" "C:\Users\Default\Documents"
mklink /j "H:\Users\Default\NetHood" "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Network Shortcuts"
mklink /j "H:\Users\Default\PrintHood" "C:\Users\Defauft\AppData\Roaming\Microsoft\Windows\Printer Shortcuts"
mklink /j "H:\Users\Default\Recent" "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Recent"
mklink /j "H:\Users\Default\SendTo" "C:\Users\Default\AppData\Roaming\Microsoft\Windows\SendTo"
mklink /j "H:\Users\Default\Start Menu" "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Start Menu"
mklink /j "H:\Users\Default\Templates" "C:\Users\Default\AppData\Roaming\Microsoft\Windows\Templates"
mklink /j "H:\Users\Default User" "C:\Users\Default"
mklink /j "H:\Users\Public\Documents\My Music" "C:\Users\Public\Music"
mklink /j "H:\Users\Public\Documents\My Pictures" "C:\Users\Public\Pictures"
mklink /j "H:\Users\Public\Documents\My Videos" "C:\Users\Public\Videos"

In those examples, “H:” is the drive letter of the Boot Camp partition. Note that the /j is used for junctions and /d is used for symbolic links. Double and triple check everything in the list. If you mess this step up, when you boot into the partition later, you’ll be logged into a temporary profile because Windows won’t be able to find your stuff. Save your list of commands to a file called “fixstuff.bat”, then double click it to run it.

SELF-CHECK: The Boot Camp partition now contains what appears to be a complete copy of the source VM’s filesystem.

3. Fix the Boot Camp partition’s mount devices and boot manager.

You need to modify the registry on your Boot Camp partition so that the boot partition is mounted in the right place. Hit Windows-R to bring up the Run dialog box. Type “regedit” and hit enter. Select the HKEY_LOCAL_MACHINE key. Now go to File -> Load Hive. Select /Windows/System32/config/SYSTEM on the Boot Camp partition. When asked for a name, type “The Boot Camp Hive”. Now within the new key, “The Boot Camp Hive”, you need to select the key for “MountedDevices”. Right click “\DosDevices\C:” and remove it. Right click “\DosDevices\X:” where X is the drive letter that you noted at the beginning of step 2, then click “Rename”. Rename it “\DosDevices\C:”. This will ensure that upon booting up the Boot Camp partition, it will be mounted as “C:”. Select the “The Boot Camp Hive” key and go to File -> Unload Hive.

Next you need to make sure your BCD store is setup correctly on the Boot Camp partition. You need to set the boot manager partition to the “H:” drive (or whatever your Boot Camp partition is mounted to), and the boot loader to the “boot” partition. You can do the boot loader part using EasyBCD (http://neosmart.net). Basically, you need to modify the BCD store (at /Boot/BCD on your Boot Camp partition) so that it has one boot loader option for Windows 7 on the “boot” partition. While you’re there look around the other options in EasyBCD. I found that to avoid the annoying boot manager menu I had to specifically check a box to skip it. Be sure to save your settings and make sure you’re modifying the right BCD store (When the program opens it’ll load the transfer VM’s BCD store instead.). Then to modify the boot manager partition run the following commands as administrator. Replace H: with the drive letter of the Boot Camp partition.

bcdedit /export C:\bcdsaved
bcdedit /import H:\Boot\BCD
bcdedit /set {bootmgr} device partition=H:
bcdedit /export H:\Boot\BCD
bcdedit /import C:\bcdsaved

Delete that temporary file we just made (C:\bcdsaved). Shut down the VM. You should now be able to boot up Windows in the Boot Camp VM. You can go ahead and install the Boot Camp drivers now.

SELF-CHECK: Using Parallels, you can boot up the Boot Camp VM and everything functions normally.

TROUBLESHOOTING: If you try to boot up the Boot Camp VM and you get a “BOOTMGR IS MISSING” error, you didn’t copy the files correctly from the source VM’s boot partition (In particular, the Boot directory is missing.).

TROUBLESHOOTING: If you try to boot up the Boot Camp VM and you get an error within the boot manager, your BCD is not correctly modified.

TROUBLESHOOTING: If you try to boot up the Boot Camp VM and you’re logged into a temporary profile, hit control-alt-delete and open the task manager. Go to File -> Run and type “cmd”. If the command line opens up to a path on the “C:” drive, you didn’t recreate the junctions correctly. If the command line opens up to a path on any other drive, you didn’t modify the registry values for the mounted devices correctly.

4. Fix the Boot Camp partition’s storage controller drivers and registry values.

At this point if you were to restart your Mac and attempt to boot natively into the Boot Camp partition you would probably get a BSOD with error 0x7b (which is INACCESSIBLE_BOOT_DEVICE). Log into the Boot Camp VM. Then follow the steps shown in the more information section on this page: http://support.microsoft.com/kb/314082

SELF-CHECK: You have a fully operational clone of your source VM.

5. Profit!

Note: Full credit for this guide goes to Christopher Brown (@ccbrown11).

13 thoughts on “Converting/cloning a Parallels VM to Boot Camp on Mac

    1. The “Source VM” is the virtual machine that you wish to convert to Boot Camp, that has your files and programs already on it. The “Boot Camp VM” is new temporary virtual machine that you create in order to facilitate the conversion process.

      Does that help answer your question?

      1. I’ve understood what means Source Machine, I guess.
        That means newly imported VM from Boot Camp partition, right?
        I stopped again at Step2: second robocopy in the transfer VM.
        Where is the source VM’s second 100MB partition?
        I apology my low skill and bad english.

        1. Second robocopy is from 100GM partiion of Transfer VM, not the Source VM. And don’t do /mir on that second robocopy command. Use /e instead. (See comments below).

          JD

  1. Is “robocopy E:\ H:\ /mir /copyall /xj /b /r:3 /w:2″ right command?
    It is deleting all files in boot camp partition copied from source VM now.
    And, VM’s boot partition (second 100MB partition) isn’t able to have drive letter in transfer VM.
    Reserved partition in transfer VM can have drive letter in itself VM.
    What’s wrong with me?

    1. Yep, “robocopy E:\ H:\ /mir /copyall /xj /b /r:3 /w:2″ is not correct.
      Try:

      robocopy E:\ H:\ /e /copyall /xj /b /r:3 /w:2

      But you’ll have to robocopy the source drive again! Wish I’d read these comments before I started. Or read the robocopy docs
      more thoroughly first.

  2. If you do both

    robocopy G:\ H:\ /mir /copyall /xj /b /r:3 /w:2
    and then
    robocopy E:\ H:\ /mir /copyall /xj /b /r:3 /w:2

    The second command will purge all the files the
    first command copied. Because /mir implies /purge
    and /purge deletes files that are not on the source drive.
    Which is everything the first robocopy copied.

  3. Hi – I followed the instructions, and am almost there! I can get Parallels to load the Boot Camp partition, and I can get Boot Camp to just barely start loading it – it BSODs shortly after the ‘loading windows’ graphic with the scrollbar appears, and then loads into OS X. Any suggestions?

    For reference: 2011 MacBook Air running OS 10.8.3, running Parallels 8. VM is Windows 7.

  4. Thank you. It took awhile but following your guide and the comments I now have my parallels on Bootcamp working like it should.

  5. I must say you have high quality content here. Your content can go viral.
    You need initial traffic only. How to get massive traffic?

    Search for: Murgrabia’s tools go viral

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>