There is this fancy new feature in Windows 7 called “Boot from VHD”. It essentially allows you to boot your machine from a virtual disk without having to virtualize the rest of your hardware. This can be quite helpful if you want to experiment with your Win7 without reinstalling all the time because you screwed up.

First I’ll explain how you can create and manage virtual disks. In the second part I will discuss how to install a second Win7 on the created virtual disk and how to set up the bootloader correctly.

There are two ways to create virtual disks. The first is by means of the “Disk Management” utility in your computer management tool (right click your “Computer” and click “Manage”). There you can create and attach virtual disks by selecting “More Actions > …”. The second way to do it is by using the diskpart command line utility. I will focus on this method because it has more options and allows greater flexibility.

A virtual disk (*.vhd) is simply a file that contains the virtual disk’s data. You can create “fixed” or “expandable” disks. For a fixed disk, the entire disk size is allocated at once while expandable disk files grow as the virtual disk is written to. There is one issue with booting from expandable disks: if you don’t have enough physical space on the disk where your VHD resides, booting from that disk will be impossible because when booting from a VHD, windows will expand the image to full size to run.

Start a command prompt as administrator and enter
> diskpart.exe
This brings you to the diskpart command prompt where you can operate on disks all you like.

Try entering
> help
or
> help create vdisk
You can use this as a reference point to learn all about windows disk management.

To create a new VHD for example, you would enter
> create vdisk file="C:\virtualdisks\myvirtualdisk.vhd" maximum=32000
This will create a new VHD file for a 32GB virtual drive.

You can’t do much with this yet. To work with the new disk, you will have to “mount” or “attach” it first
> select vdisk file="C:\virtualdisks\myvirtualdisk.vhd"
> attach vdisk

And once the disk is virtually attached to your system, you can continue by setting it up properly
> create partition primary
> assign letter=X
> format quick label=VirtualDisk

This will make the disk accessible as drive X: (properly formated and labeled).

Now you can start using the virtual disk as you would any regular disk, OR you can try to install another Windows 7 on it and boot the new installation. I’ll explain how to do that in the next part of this discussion.

1 Comment


Leave a Reply

Your email address will not be published.

*