Boot Windows 7 From VHD!

In the virtualisation space, one of the often demo’ed features of the upcoming Windows 7 / 2008 R2 is the ability to boot directly from VHD. Microsoft have effectively created a “loopback HBA”, which the bootloader can use to address VHD’s just like a regular disk. This is pretty cool for a whole host of reasons, and easy to achieve.

1. If you’re going to install another Windows 7, first set the boot menu description of your current installation with bcdedit /set {current} description “Windows 7 HDD”

2. Now create a new VHD. You can do this via the GUI in disk management, or via the CLI with diskpart. Since you’re gonna need diskpart for the install, might as well use that now. I’m sure you can figure out what I’m doing with diskpart create vdisk file=d:\vhd\windows7.vhd type=fixed maximum=20000

3. Installation time. Drop in your Windows 7 installation media, reboot and when u get to the first screen prompt of the installation hit Shift+F10 to bring up a command window. Run diskpart, then enter select vdisk file=d:\vhd\windows7.vhd, then enter attach vdisk, then exit diskpart. Note that if you have multiple physical disks, Windows PE may not have honoured your drive letter assignments. Enter list vol from within diskpart to see what it’s done if you run into any trouble.

4. Continue the installation process, and when you get to the choice of disks to install onto, you should see your VHD sitting in the list of available options just like a regular disk.

5. Select the VHD and go read something while the install finishes. You’re done!

When the machine reboots, you’ll notice that the VHD boot menu option is now the default. This can be easily changed using bcdedit from within either of the Windows environments you have booted into.

Next thing I’ll probably try is to see just how much I can cut down the original install so I can use VHD’s for everything, kind of like a semi-client hypervisor. Sounds like a perfect job for Server Core… hopefully it’s functional enough to be able to do this, I can’t imagine why it wouldn’t be.

UPDATE Just been messing around with server core in a VM, looks like all systems are go. Using the same commands as above I could create / attach / format a VHD. Server core looks _great_ in 2008 R2. Installing PowerShell and launching it nearly brought a tear to my eye… finally server core has arrived.

UPDATE 2 Reader Patrick S has just pinged me to let me know that this technique also allows for installation of Windows XP / Server 2003 as well! I assume you’d need to use the Windows 7 PE environment or something… but he’s done it, so there’s a way. Nice one Patrick, thanks for the heads up!

Advertisements

Tags: ,

One Response to “Boot Windows 7 From VHD!”

  1. J. Edgar Says:

    Hi,
    It would be great to see how this works with XP and Vista. I have tried using the Windows 7 PE CD to install XP to VHD but with no luck.

    Could you please ask Patrick S to elaborate on his method a little bit and post it on your blog. Or you can email it to me if you wish.

    Thanks.
    J.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: