Playing with VHDs under Windows 7

July 9th, 2009

Windows 7 supports booting from VHD, which opens a new world to play with. There are quite a few good sites talking about this, for example, Microsoft Technet, or Aviraj Ajgekar’s Blog. Here I just want to note down my experiments so that I can dig it myself later.

My purpose is very simple: I want to take snapshots of my installation, and I want it easy revertible so that I don’t need to wait for Ghost to image back my stuff. This will be pretty useful when the machine is exposed in hazardous area (e.g. users with bad browsing habits!). How to do this? Boot the machine with Windows 7 DVD, and press Shift-F10. A Command Prompt will show up. My planning is:

B drive: 200MB for bootloader
C drive: 100GB for VHD
P drive: all remaining available for shared data
It’s better to have higher capacity for C because the page swap and other stuff will be placed within the same drive where the VHD files resides.

I completely wiped out my hard drive, since it’s brand new:

sel disk 0

Then create the B, C, and P drive:

create partition primary size=200
format quick fs=ntfs
assign letter=b
create partition primary size=102400
format quick fs=ntfs
assign letter=c
create partition primary
format quick fs=exfat
assign letter=p

Now we can create the VHD file we want to install Windows 7:

create vdisk file=c:\win7.vhd maximum=40960 type=expandable
select vdisk file=c:\win7.vhd
attach vdisk
create partition primary

After these commands done, we can close the Command Prompt and proceed to Windows 7 installation. Select “Custom Install”, and install Windows to Disk 1. Windows Setup will complain that it can’t be installed on Disk 1, just ignore it. If VHD type is expandable, you need to make sure the VHD’s maximum size does not exceed the real size of its residual partition, otherwise a BSOD will be what you get after reboot.

Windows will take care of the proper configuration of boot loader, so just enjoy it. I’ll detail how to snapshot it in next article.

Technical, Windows | Comments Jump to the top of this page

Comments are closed.

Chef Peon's Melange



Social Links