Windows 7 supports VHD natively and it has lots of benefits. We have already posted Native VHD Support in Windows 7, which covers “What’s new in Windows 7 for VHDs. In this blog post, we’ll explore some practical use of VHDs, like Create/Attach/Detach/Format VHDs and make bootable VHD of Windows 7.
Windows 7 VHD acts like the same Real OS(Windows 7 on physical machine). It has some sort of limitation but it is excellent addition to Windows 7 and help for IT Pro, Devs and Testers. The Goals for Native Support for VHDs in Windows Server 2008 R2 and Windows 7 are as follows:
- Simplify the experience of creating, managing, and deploying Windows images across both physical and virtual machines using a single image format and common tools.
- Enable systems to have multiple instances of Windows installed without using separate disk partitions for more flexibility to change server application workloads as needed.
- Enable efficient development and testing for software that requires an isolated test environment using a common image that runs on either a physical or virtual machine
Lets come to the point and start it.
Required:
- A PC running Windows 7/Windows Server 2008 R2
- Install.wim Image files of Windows 7/Windows Server 2008 R2, is found in sources folder of DVD
- WAIK for Windows 7/Windows Server 2008 R2
I have created a folder called VHD on root of C: drive and copied Windows Server 2008 R2’s install.wim and will use the folder to create VHD as well. So the location of files etc. may differ.
How To:
1. Run elevated Command Prompt and launch Diskpart utility. On DISKPART prompt, execute the following commands one by one.
create vdisk file=C:\VHD\W08R2x64.VHD Maximum=25000 Type=Fixed
It creates a VHD file named “W08R2x64.VHD” with maximum size of 25000MB. It is the time taking process. There are two type of VHDs can be created.
Dynamic: The size of VHD increases as data is written to it.
Fixed: The size of VHD is fixed and doesn’t increase as data is written to it.
attach vdisk
Attaches the VHD to disk list, you can check it by executing list disk.
sel disk 1
Selects disk which has ID#1, for more info see the results of list disk command.
create part primary
It creates a primary partition and usages all available space of VHD i.e. 25000MB or approx 24GB.
format fs=ntfs quick
Quick format the partition with NTFS file system.
assign
Assign a drive letter to the partition. for instance G:
active
Mark as the active partition. finally exit and leave the diskpart.
Once you are done. you’ll see an extra drive in Computer i.e. the partition of VHD, because the vdisk is still attached.
2. Now run elevated Deployment Tools Command Prompt (If UAC is enabled)
Start > All Programs > Microsoft Windows AIK > Deployment Tools Command Prompt and execute the following command to copy the Windows 7 to VHD partition.
imagex /apply C:\VHD\Install.wim /check 3 G:\
Copy the OS files(which has Index#3) to G: drive(VHD partition). Where /check
To know about Index, you can execute the following command imagex /info C:\VHD\Install.wim which will display WinInfo with all available index associated Windows editions.
3. Now we need to use diskpart once more to detach the VHD.
First command selects VHD and second one detaches.
4. Now we are to add boot entry in BCD using bcdedit.exe command, which is so easy as A,B,C.
bcdedit /copy {current} /d “Windows Server 2008 R2 – VHD”
Here we are copying BCD data, because both OS are same. The command creates a copy all settings of currently running Windows i.e. Windows 7. It also adds boot entry with an unique identifier. See {47aa7c3d-833d-11de-afc5-dec4cb4d83bb}. It may differ PC to PC.
Now we need to modify device and osdevice for VHD’s boot entry which Unique ID is {47aa7c3d-833d-11de-afc5-dec4cb4d83bb}
bcdedit /set {47aa7c3d-833d-11de-afc5-dec4cb4d83bb} device vhd=[C:]\VHD\W08R2x64.VHD
and
bcdedit /set {47aa7c3d-833d-11de-afc5-dec4cb4d83bb} osdevice vhd=[C:]\VHD\W08R2x64.VHD
5. Now reboot your PC and perform few essential part of installation, like installing device drivers, updating registry and services, creating User account and set regional date/time/languages etc. When you are done… Your Windows 7 VHD is ready to use.
Leave a Reply