Tuesday, January 18, 2011

Native-Boot Differencing VHDs in Windows 7 - I did it, now what?

Windows 7 has a feature called Native-Boot Virtual Hard Disks. You can boot to a file on your hard drive (a virtual hard disk file) that contains all the files and folders of your operating system - either Windows 7 Ultimate or Enterprise or some versions of Windows Server 2008 R2. You can create a file based on the container virtual hard disk (VHD) file that tracks the differences or changes you make when you're running from the that file called a differencing VHD. A differencing VHD file is useful if you need multiple VHD files that share a common base (or parent). It's quicker and uses less space as the number of VHDs that you need increases. Also, you can experiment in a differencing VHD without worrying about messing up the original VHD. You cannot (as yet) update many differencing VHD files simply by updating the parent VHD.

This was my experiment:
1) Boot from the Windows 7 Ultimate install DVD.
2) At the Install Now screen, press SHIFT+F10 to get a command prompt
3) Partition and format the drive as needed. Since I was using a Dell Latitude, I left the diagnostic, recovery, and Latitude Reader On (an instant boot feature) alone. I deleted the original OS partition, created a new partition, and formatted it. For me, the steps were as follows:
a) Type diskpart and press enter
b) Type list disk and press enter; identify the disk, type select disk 0 and press enter (replace 0 with the correct disk number)
c) Type list part and press enter; identify the partition, type select partition 3 and press enter (replace 3 with the correct partition number)
d) Type delete partition and press enter
e) Type create partition primary and press enter (you can specify a size using size=, otherwise the new partition claims the remaining space)
f) Type format fs=ntfs quick and press enter (without "quick", a full format is performed).
g) Assign a drive letter. To list used drive letters, type list volume and press enter; type assign letter=c (substitute c with an unused drive letter)
4) Create the vdisk and attach it:
a) (While still in diskpart) Type create vdisk file="c:\Windows7.vhd" type=fixed size=51200 and press enter (type can be fixed or expandable and size needs to be smaller than the drive you choose)
b) Type select vdisk file="c:\Windows7.vhd" and press enter.
c) Type attach vdisk and press enter.
d) Type Exit and press enter
5) Switch to the install screen and press Install Now. Install Windows 7 to the VHD you created (you can ignore the “Windows cannot install to this disk” warning note). I picked a custom install and installed to the unused space that represented the VHD.
6) Customize your parent or base VHD as desired. I installed drivers, Windows Updates, Microsoft Office, Adobe Acrobat, virus protection, and some of our company's vendor's software.
7) Reboot and boot from the installation DVD (I think this can be done in Windows 7 from an run as administrator command prompt, this is just how I chose to do it).
8) Press SHIFT+F10 to get the command prompt again.
9) Type diskpart and press enter.
10) Type create vdisk file="c:\Win7Diff.vhd" parent="c:\Windows7.vhd" type=expandable maximum=51200 and press enter (filename, type, and maximum size are up to you)
11) Type Exit and press enter
12) Type bcdedit /v and press enter.
13) Highlight and copy (right-click) the identifier for the Windows Boot Loader for the boot VHD.
14) Type bcdedit /copy [press space then right-click to paste the identifier] /d "Windows 7 Differencing VHD" and press enter (contained in the quotes is the name you want displayed from the boot menu, I chose "Windows 7 Differencing VHD").
15) Highlight and right-click to copy the new guid.
16) Type bcdedit /set [press space then right-click to paste the identifier] device vhd=[c:]\Win7Diff.vhd and press enter
17) Type bcdedit /set [press space then right-click to paste the identifier] device vhd=[c:]\Win7Diff.vhd and press enter
18) (If you want this to be your new default) Type bcdedit /default [press space then right-click to paste the identifier] and press enter.
19) Reboot

Like so many other things I experiment with before I have a reason to undertake the task, I was left with the feeling - cool, now what. This was my main source for the procedure: http://blogs.msdn.com/b/knom/archive/2009/04/07/windows-7-vhd-boot-setup-guideline.aspx

No comments:

Post a Comment