click tracking
Windows 7 RC and support for VHD (including booting from VHD) - Katrien's MSDN Blog - Site Home - MSDN Blogs

Windows 7 RC and support for VHD (including booting from VHD)

Windows 7 RC and support for VHD (including booting from VHD)

  • Comments 7

I’m loving the new Windows version, I’ve been using it on my work and my demo computers since the release of the Beta version in January. I’m not going back!
Now with the release of Windows 7 RC we are coming closer to a scheduled release by holiday season 2009 (as announced during TechEd US keynote).

Expiration of Beta and RC versions
If you are using the beta version yourself it’s recommended to upgrade (actually do a clean install) for RC. The beta version will be expiring in July 2009.
Windows 7 RC install will expire in February 2010.

Note that the RC version is available for download until the end of June 2009, from the MSDN site.

VHD support

One of the interesting features in Windows 7 is support for VHD. There’s support in two ways: first is being able to create and mount a VHD file as a disk in the OS.

This is done through the Disk management settings under Computer Management.
image

The second feature is booting from a VHD file. As my colleague Arlindo explained to me, this is not running on vritualization technology. It’s done through the boot loader which will unpack the VHD and then boot from there. So it’s not the same as running your VHD with Virtual PC.

Creating a bootable VHD

To create my bootable VHD I used a few sites with to gather the information and guide me through the process. These were:

Because an existing VPC is not supported to be used as a bootable VHD, you are obliged to follow one or other procedure in order to get a new Windows 7 installed on the VHD. Basic steps are, as I followed from Cesar’s post:

  1. After the base Windows 7 OS is installed, restart the computer and run from Windows 7 DVD. Note: it
  2. Choose Windows Repair (or press Shift+F10 to load the command line at the first install screen)
  3. Start the Command prompt.
  4. Type Diskpart
  5. Diskpart utility will load. Type create vdisk file=c:\Windows7Build7000.vhd maximum=40000 (where “c:\Windows7Build7000.vhd” can of course be another location and name). The 40000 refers to the disk size. Adapt as required.
  6. Enter the command to select the newly created disk: select vdisk file=c:\Windows7Build7000.vhd
  7. Type: attach vdisk
  8. Type: exit (you exit Windows Repair, but Do Not Reboot), or close the command line
  9. Click “Install now” back in the installation wizard.
  10. Accept license and then make sure you choose “Custom (advanced")” in the installation type screen.
  11. Choose the newly created disk as a destination (by checking the size of your newly created VHD you should be able to recognize which one it is.
  12. If you get a warning saying that your computer hardware might not support this drive just ignore it.
  13. Continue installation wizard, Windows 7 gets installed and will reboot the system a few times. That’s it.

After following this procedure I ended up with two Windows 7 entries in my boot sequence so this is something that needs to be addressed. I found out the last install (on VHD) is put at the top.

100_1021

The only change needed here is adapting the entries in the boot loader so that I know exactly which one is which. To do this we can use the bcdedit.exe command line tool.

The bcdedit tool is pretty straightforward (see TechNet document on command line options). What I need to do is rename the VHD Windows 7 entry to something that is more logic, and secondly I would like my base OS to appear as the first in the dual boot option. To do this I opened up command line in admin prompt, and used these commands.

bcdedit /v
This command will list the boot loader entries. Copy the GUID for the VHD entry onto clipboard.

bcdedit /set {GUID} description “Windows 7 – VHD”
Setting the entry description, you can of couse choose whatever description fits you.

bcdedit /displayorder {guid} /addlast
Here we set the display order of the VHD entry to be displayed last. Since the entry already exists it’s simply moved to the end of the list.

Now since I also want to make sure the first entry gets selected by default when booting, I copy the base OS GUID to clipboard and then use the /default option:

bcdedit /default {GUID}

With that I’m all set: my main install I’m using for my main (released) version demos and keeping the VHD for trying out all beta versions of technologies. And my boot entries show as I have set:
100_1022

Sleep mode also continues to work perfectly, indifferent from the fact that it’s been booted on the VHD or the base OS.

To finish off, another interesting advantage of having a bootable disk on a VHD: you can use BitLocker to encrypt the whole disk where the VHD sits: if by any your laptop gets lost or stolen there’s no way to get the VHD’s content.

  • PingBack from http://microsoft-sharepoint.simplynetdev.com/windows-7-rc-and-support-for-vhd-including-booting-from-vhd/

  • thanks for the extra details in the post!

    It looks like creating a dynamic size disk works with this setup.  adding TYPE=expandable to your create VDISK command will work.

    the creation of the vdisk is instant, but it takes a bit longer to install, because of the resizing... though not the ~20 min to create the 40 gb fixed disk

    finishing up install on it now. i am going to try a differencing disk next.  this will save loads of space, and i think it will save time creating a full install of the OS every time

  • the differencing disks seem to work pretty well!  you have to manually create the bcdedit entries, but they were not too complicated... i just duplicated the base VHD settings.  

    bcdedit /create /d "Windows 7 - Dev VHD" /application osloader

    -- this will return a new guid

    bcdedit /set {guid} device vhd="[D:]\vdisks\win7_dev.vhd"

    bcdedit /set {guid} osdevice vhd="[D:]\vdisks\win7_dev.vhd"

    bcdedit /set {guid} path \Windows\system32\winload.exe

    bcdedit /set {guid} nx OptIn

    bcdedit /set {guid} locale en-US

    bcdedit /set {guid} inherit {6efb52bf-1766-41db-a6b3-0ee5eff72bd7}

    bcdedit /set {guid} recoverysequence {b530dc85-4317-11de-b0e2-c1dc6491d533}

    bcdedit /set {guid} recoveryenabled Yes

    bcdedit /set {guid} resumeobject {b530dc83-4317-11de-b0e2-c1dc6491d533}

    bcdedit /set {guid} systemroot \Windows

    bcdedit /displayorder {guid} /addlast

    so, pretty cool.  and i used the x64 install on the vhd. not sure if this will cause issues, though

    thanks again

  • Thanks for the extra details! I was also thinking about the dynamic disk settings.

    Possible that the x64 might give you some differences but it should work as well.

    Thanks again for sharing!

    Katrien

  • Great post!

    If I create a Windows 7 .VHD in Windows Server 2008 Hyper-V, will I then be able to boot directly on this .VHD ?

    Do you know how to add this existing .vhd to the boot loader ?

  • I'm not sure the .VHD you create will on hyper-v will supported in this way. Anyway you might want to try that.

    Adding a new reference to the boot loader is done through the bcdedit tool, using the /create command. Actually look at the comment by james_novak just above yours for an idea on how to do this.

  • I have setup my new windows 7 instance inside a vhd. I would like to use that now as my native installation.

    I made an image backup of the running vhd instance and wanted to restore it directly to the hdd, what does not seem to work.

    Is something like that possible?

Page 1 of 1 (7 items)
Leave a Comment
  • Please add 8 and 8 and type the answer here:
  • Post