Windows 7 VHD Install – part 5

Let’s wrap it up, and it’s going to be a big one. After showing how to install Windows 7 on a VHD disk, what to do if we want to attach additional VHD’s, do a move to new hardware and finally backup and disaster recovery procedures, it is now time for the big finale! Let’s start right away:

Disk to VHD migration

What if you want to have your Windows 7 running in a VHD, but rather not start all over again installing the OS, etc. etc.? Migrating an existing Windows 7 (installed on the hard disk) to a VHD installation can be done, but requires more steps. First of all you need the following:

  • USB hard disk.
  • Windows 7 installation DVD.
  • Sysinternals Disk2vhd tool (freeware).
  • Xcarab VhdResizer (freeware).
  • Microsoft Windows Virtual PC, not necessarily on the computer you’re migrating but can be on any PC.
  • A partition editor boot CD, such as Acronis Disk Director or GPartEd (freeware).

Here we go:

– First we’ll do some preparatory steps:

  • Remove BitLocker from the all partitions, if these have been BitLockered. Merely suspending BitLocker instead may also work, it is certainly a much quicker approach. I haven’t tested it like that though, and to be safe I would rather take the extra time and do a full removal.
  • Disable the pagefile. If you can’t disable it, place the pagefile on a (temporary) partition that won’t be migrated.
  • Reboot.
  • In Disk Manager, resize the system partition to 30 GB. Should Disk Manager not allow you to shrink the partition that much, revert to booting the partition editor CD and shrink the partition offline.
  • If you have more partitions to migrate to VHD’s, resize them as well to the desired (maximum) sizes of the new VHD’s. Do note size them larger than 127 GB, because some tools (like Disk2vhd and partition editors) will not work well with larger files.

– Next, we’ll create the VHD(‘s). The system partition is shown here as an example:

  • Plug in the USB hard disk.
  • Open Disk2vhd.
  • Under VHD File name, type a name of your choosing, on the USB disk. Note: this name best reflects its role as the system partition.
  • Under Volumes to include, make sure you only have the C:\ drive enabled.

  • Click Create to start.
  • Create additional VHD’s as you require. There is however no need to create a VHD for the 100 MB “System Reserved” partition.

– Now we’ll have to modify the VHD(‘s). The way Disk2vhd works, it has only copied the selected partition but the original partition structure for the whole disk is also still present. We’ll need a partition editor to change this, and the way to do it with a VHD is mounting it on a virtual machine.

  • In Windows Virtual PC, create a new virtual machine, add your just created VHD(’s) as its hard disk(s).
  • Do not enable undo disks in the virtual machine.
  • Start the virtual machine and let it boot from your partition editor boot CD.
  • In the partition editor, per disk delete all partitions but the one that is supposed to remain on that particular VHD. For instance on the system VHD keep the 30 GB system partition.
  • For each disk, move the remaining partition to the beginning of the disk.

  • After this has completed, close and delete the virtual machine.

– Almost there… The obsolete partitions are gone, but we still need to remove the un-partitioned space from the VHD(‘s). Again, the system partition is shown here as an example:

  • Open VhdResizer.
  • Select the system partition VHD on the USB disk.
  • Under Destination VHD, choose a temporary path. Do not try to overwrite the source file.
  • Leave Type as Dynamic.
  • Set the New Size to 30720 MB (30 GB).

  • Click resize. It will take a while to finish.
  • When done, replace the system partition VHD on the USB disk with the one you just created with VhdResizer.
  • Resize your other VHD’s as you require, then close VhdResizer.

– Close Windows and do a fresh install of Windows 7 on a VHD, as explained earlier. Note that the name of the system partition VHD must be the same as the system partition VHD you have just created with Disk2vhd! Other setup configuration is irrelevant, you can simply click Next and enter “bla bla” where needed.

– Let the setup finish until you finally see the user’s desktop.

– Reboot from the Windows 7 installation DVD again.

Shift-F10 at the language and keyboard selection screen.

– Copy the VHD’s on the USB disk (likely to be F: now) to your VHD folder on the hard disk (likely to be D: now), replacing the system partition VHD.

– Type the following commands. Of course change the path and VHD name to your own system partition VHD. The last bootrec command should find one Windows installation, answer it with Y(es).


    select vdisk file="d:\VHD\<name>.vhd"

    attach vdisk


bootrec /fixmbr

bootrec /fixboot

bootrec /rebuildbcd


– If you are also moving to different hardware, you must set HAL (Hardware Abstraction Layer) detection on. Typing bcdedit /set detecthal on will do the trick.

– Exit the Windows 7 setup and reboot.

– If all went well, Windows 7 will boot without any problems.

– Restart Windows if asked to do so.

– If required, attach the additional VHD’s as described before.

– Re-enable the pagefile.

– Re-apply or enable BitLocker, if needed.

– You must most likely re-activate Windows.

– If you have previously set HAL detection on, it is now safe to turn this feature off again. Open a command prompt with administrator privileges, and type bcdedit /set detecthal off.

– As stated earlier, the Windows Performance Index doesn’t work on an VHD’d Windows 7. However, because you have just migrated your Windows 7 from a physical hard disk installation, you still have a valid index you probably want to keep. Therefore you must as soon as possible disable the periodic re-calculation of the index. Go to the Task Manager and disable the WinSAT task under Windows / Maintenance. Of course, also don’t run the index re-calculation manually…



That’s it. I can only hope someone will find this series of posts useful. The only thing I can add is that I have tested and used all procedures myself, without any failures. I have been running my Windows 7 on VHD’s for a year now, without a hitch. Also, don’t forget this works for Server 2008 R2 too! I even dared to do a migration from physical to VHD disks on a “live” server, and not regretting it for one second.


Posts in this series:

Leave a Reply

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