Native VHD Boot Guideline in Windows 7

Wednesday, 25 November 2009 14:26 by scngan

One of the many new features of Windows 7 and Windows server 2008 R2 is the Native VHD (Virtual Hard Disk) Boot.

Native VHD boot will support Microsoft’s customers with a way to use a single disk format to service both virtual and physical clients alike.

Why VHD Boot ?
If you use virtual PC, you are sharing your hardware resources but

If you use VHD Native boot, you VHD are actually fully control and use your hardware resouces.

To create your own native VHD boot in your Windows 7 Machine, you can follow the following guide.

System Requirement
- Windows 7 Ultimate, Enterprise
- Windows Server 2008 R2 (all versions)

Prerequisites
- Backup your current Boot Configuration Data Store (BCD).
- Windows 7 Enterprise ISO Image.
- ImageX Tool - (Download - ImageX_x86.zip (720.21 kb))
After download, extract and copy the file to your C:\Windows\System32
- Administrator Right to your computer.
- Command Prompt with Administrator Right.
 
Backup BCD
Run your command prompt with administator right. The type the following command.
C:\ bcdedit /export c:\bcdbackup

Above figure show that i backup my bcd into my D:\ drive

After backup your BCD, now, you will need to create the VHD file.

There are 2 way of doing it, the way that i show here will be using command line - DISKPART. Another method of doing is by using Disk Management GUI.

Create VHD using DISKPART
Run you command prompt with Administrator right again.
Type the following (in BOLD):

diskpart
create vdisk file=c:\windows7.vhd maximum=25600 type=fixed
(above command means : Create a VHD File in C:\ with the filename of Windows7. Harddisk size is : 25 GB. Harddisk size Type is fixed)
## It will take some times (around 10 minute) for Windows 7 to create the VHD ##
select vdisk file=c:\windows7.vhd
(select the virtual disk that you want to use)
attach vdisk
(Attached the virtual disk to you PC)
create partition primary
(create a primary partition in the virtual drive)
assign letter=v
(Assign a drive letter to the virtual drive, in this case will be "V")
format quick label=Win7VHD
(Make a quick format either with Windows GUI or command prompt. Label the drive with Win7VHD)
exit



Your windows should prompt you that a new drive being detected in your My Computer with the Drive V.



Once you ready with your VHD file, now is the time to load the image (Install.WIM) to your VHD.

In our case, we will be using Windows 7 Enterprise ISO. 

But before we start to apply the image, we need to know what's the windows SKU/Index number contain in the INSTALL.WIM file.

Check the windows SKU/Index number
In your command prompt type :

dism.exe /get-wiminfo /wimfile:"C:\Sources\Win7Ent\sources\install.wim"


In this case, the SKU/Index number will be "1".

The index number is the number to remember, we will be using this number when we apply the data tot the virtual disk.

Now we are ready to load the image to the VHD file.

Load Image to VHD using ImageX
Back to your command prompt.

imagex.exe /apply "c:\sources\Win7Ent\Sources\install.wim" 1 v:

 
It will take aorund 5 to 10 minute to complete.


So, now you already have a VHD with Windows 7 Enterprise images loaded.

The next step will be on adding your VHD into your windows boot menu.

*** PLEASE MAKE SURE YOUR BOOT CONFIGURATION ALREADY BACKUP BEFORE YOU CONTINUE HERE *** 

To boot the VHD in your startup, BCDEdit command will be use.

Before we add in the new option, let us see what we have in our BCD Store by using

Check BCD Store
Open the command prompt.

bcdedit.exe /enum


This is what i have in my BCD Store for my computer.

Next, we will copy the above BCD Store info to make a new BCD for the VHD.

Copy default BCD
In command prompt,

bcdedit.exe /copy {current} /d “Windows 7 VHD Boot”
(the above command is to copy the BCD from the above {current} store and create a new entry with a new Windows 7 VHD Boot as the description)



So, you have just copy the BCD with the entries {d536e101-d999-11de-aa89-24b957ec8ab9}.

Remember to copy down the entries GUID !


Now, let us view our BCD again.


We now have a new entry {d536e101-d999-11de-aa89-24b957ec8ab9} with the description of "Windows 7 VHD Boot"

We need to change two crucial settings in the newly created boot loader entry.

These settings tell the Windows boot manager to look for a VHD file during Windows booting initialization as the above DEVICE is poiting to the C:\ and not the VHD device. 

Pointing VHD in BCD
Command Prompt,
 
bcdedit.exe /set {d536e101-d999-11de-aa89-24b957ec8ab9} device vhd="[locate]\windows7.vhd"
bcdedit.exe /set {d536e101-d999-11de-aa89-24b957ec8ab9} osdevice vhd="[locate]\windows7.vhd"
 

The setting [locate] will instruct the Windows Boot Manager to locate the VHD without you having to specify a drive letter at creation time.


The 2 command that run successfully.

Now, check out BCDedit /enum again.


Your BCD already pointed the VHD under the DEVICE.

Since we will be doing an installation of Windows, we will also need to be able to detect the hardware abstraction layer (HAL) during setup.
Therefore we need to enable a final setting to make this possible. 

Enable HAL
Command Prompt,

bcdedit.exe /set {d89f3fa4-6416-11de-b070-b08b383b8f33} detecthal Yes

 

The above figure show that Windows Boot Loader will boot the VHD with the HAL support.

Optional :
To set the VHD boot loader entry as the default boot configuration, use the following “bcdedit.exe” command: 

Bcdedit.exe /default {d89f3fa4-6416-11de-b070-b08b383b8f33}

The final step will be detach the VHD from your computer. This will prevent data corruption if you reboot the computer with the VHD still attached.

If the VHD would remain attached there’s always a possibility that files would remain open or locked and the data on the VHD would eventually be damaged.

There are also 2 way of doing it. The first one will be using the Disk Management and the second way will be using DISKPART command.

In my example, i will be using DISKPART command. 

Detach VHD using Diskpart
Command prompt,

diskpart
select vdisk file=C:\windows7.vhd
detach vdisk
exit




You are done with the all the step needed to do native vhd boot.

Restart your computer now and you will see the new boot selection menu.

Select the Windows 7 VHD Boot and start the installation of your VHD Windows 7 Enterprise ! 

To restore back your original BCD Store Backup
Command prompt,

bcdedit.exe /import d:\bcdbackup

It will restore back your original boot loader.

Currently rated 4.8 by 4 people

  • Currently 4.75/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   MVP | Technical Stuff
Actions:   | E-mail | Permalink | Comments (2) | Comment RSSRSS comment feed

Comments

Comments are closed