Home > Uncategorized > Preparing the VHD file using Windows Server 2008 Hyper-V

Preparing the VHD file using Windows Server 2008 Hyper-V

If you have Windows Server 2008 running Hyper-V, launch the virtual machine running Windows 7 or Windows Server 7 aka Windows Server 2008 R2 and the run the following command

c:\windows\system32\sysprep>sysprep /generalize /shutdown

 note: you can skip this step, if the system administrator already run the previous command. You need to check this  with him.

 

After running the above command in the virtual machine, this will launch the System Preparation Tool 3.14. Select the checkbox for ‘Generalize’ and click on OK.

Once the sysprep is completed the virtual machine will be shutdown and ready for booting. You can copy that VHD now.

 

Setting up your Windows Boot Menu to boot to an Existing VHD

If you have an existing Win 7 VHD already, or perhaps you’ve taking your Windows 7 installation Disc and “syspreped” a VHD image. Now, from an Administrator Command Prompt, you need to tell the Windows Boot Manager that there’s another option. You go:

C:\>bcdedit /copy {current} /d “My New VHD Option”

This will return a GUID. Select it using the Mark command by right-clicking in the Command Prompt and copy it to the clipboard.

Now, using that {guid}, type these commands:

C:\>bcdedit /set {guid} device vhd=[driveletter:]\<directory>\<vhd filename>
C:\>bcdedit /set {guid} osdevice vhd=[driverletter:]\<directory>\<vhd filename>
C:\>bcdedit /set {guid} detecthal on

See the [driveletter:] stuff in brackets? It’s NOT obvious, but you need to include those, so:

bcdedit /set {guid} device vhd=[C:]\win7\win7.vhd

You can confirm it’s setup with bcdedit /v:. You’ll see something like this. The interesting part is at the bottom.

Windows Boot Manager
——————–
identifier              {9dea862c-5cdd-4e70-acc1-f32b344d4795}
device                  partition=C:
description             Windows Boot Manager
locale                  en-US
inherit                 {7ea2e1ac-2e61-4728-aaa3-896d9d0a9f0e}
default                 {34433bb7-628f-11dc-a941-001a6bcd5d3a}
resumeobject            {34433bb8-628f-11dc-a941-001a6bcd5d3a}
displayorder            {34433bb7-628f-11dc-a941-001a6bcd5d3a}
{280ffa1e-f8a9-11dd-b0a9-001c26fdc6b4}
toolsdisplayorder       {b2721d73-1db4-4c62-bf78-c548a880142d}
timeout                 30
custom:45000001         1

Windows Boot Loader
——————-
identifier              {34433bb7-628f-11dc-a941-001a6bcd5d3a}
device                  partition=C:
path                    \Windows\system32\winload.exe
description             Windows 7
locale                  en-US
inherit                 {6efb52bf-1766-41db-a6b3-0ee5eff72bd7}
recoverysequence        {280ffa1b-f8a9-11dd-b0a9-001c26fdc6b4}
recoveryenabled         Yes
testsigning             Yes
osdevice                partition=C:
systemroot              \Windows
resumeobject            {34433bb8-628f-11dc-a941-001a6bcd5d3a}
nx                      OptIn
custom:42000002         \system32\winload.exe
custom:45000001         2
custom:47000005         301989892
3

Windows Boot Loader
——————-
identifier              {280ffa1e-f8a9-11dd-b0a9-001c26fdc6b4}
device                  vhd=[C:]\VMs\Win7\Win7.vhd,locate=custom:12000002
path                    \Windows\system32\winload.exe
description             Win 7 VHD – Dev10
locale                  en-US
inherit                 {6efb52bf-1766-41db-a6b3-0ee5eff72bd7}
recoverysequence        {280ffa1b-f8a9-11dd-b0a9-001c26fdc6b4}
recoveryenabled         Yes
testsigning             Yes
osdevice                vhd=[C:]\VMs\Win7\Win7.vhd,locate=custom:22000002
systemroot              \Windows
resumeobject            {34433bb8-628f-11dc-a941-001a6bcd5d3a}
nx                      OptIn
detecthal               Yes
custom:42000002         \system32\winload.exe
custom:45000001         2
custom:47000005         301989892
3

If it doesn’t work, you can always run bcdedit /delete {guid} /cleanup and try again.

Here’s what my Boot Manager (pressing F8 when I start up my machine) looks like now:

Now, I can boot up with my VHD mounted. Am I running a Virtual machine? No. I’m running Windows, on the hardware, with only the DISK Virtualized. I don’t work for that team, but I’m guessing I’m losing 3-5% (that number came out of my butt) on the disk side – and nothing anywhere else. How do I know? Well, Windows Experience is smart enough to keep me from checking (although I could use another disk tester tool, but I’ll leave that as an exercise to the Reader.).

I notice that Disk Management still gives me access to my was-C: drive, even though the VHD is now my C. My hardware C: drive got moved down, and it’s E: now. Nice than I can still see it!

What does the Device Manager say? It says the Msft Virtual Disk SCSI Disk Drive is there! That’s the only “virtual” thing going on here. Notice I’ve still got my actual Video Drivers (running multiple monitors across multiple display drivers). All my stuff is there, because I’ve got, forgive me, less virtual and more machine.

Hey, are those my four processors and my 8 gigs or RAM? Ah, yes, they are.

Love it. I’m going to use the hell out of it.

A few caveats. One, I haven’t figured out how boot off a VHD that is on USB or External Drive. I’m looking into it. It may be because there’s no drive letter assigned yet, or that I’m an idiot. We’ll see. Second, doing this makes your VHD less portable, because if you move it inside Virtual PC or to another machine, all the devices will freak out and try to reinstall (or maybe just not work) so be aware of that.

That said, I’m running Visual Studio 2010 Beta 1 without fear on my awesome hardware with hardware-speeds. Shiny.

Related Links

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

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: