How to clone your system drive with Windows 7 VHD boot
When I try to build multiple demonstrations on one laptop, I found it's not best choices to install multi OS instance on different partition. While, Windows 7/Vista can provide the capability to boot from VHD directly, could resolve these problems very well. Additional, by using differential disk, I could save a lot of disk space.
The steps will be like this:
- Prepare VHD
- Method 1
-
-
- Install Win7 and applications on VHD file directly
- Knom's Blog have a good step-by-step guide to help you complete this. https://blogs.msdn.com/knom/archive/2009/04/07/windows-7-vhd-boot-setup-guideline.aspx
- Install as C:\VHD\WIN7ENT_BASE.VHD
-
-
- Method 2
-
-
- Capture current system drive on hard disk.
- By default, Win7 will create 100M system reserved partition, and then take 100% spare disk space to be system partition.
- Capture your system drive and convert it into VHD
-
-
-
-
- Boot by Win7 DVD/USB click repair mode or boot into WinRE/WinPE
- Using imagex.exe to capture the system drive to wim file on USB drive. Imagex.exe can get from WAIK installation folder. Also, https://www.autoitscript.com/gimagex/ can provide a simple GUI for imagex.exe.
- Create VHD file on physical disk, by diskpart.exe
-
-
create vdisk file=" C:\VHD\WIN7ENT_BASE.VHD" maximum=32768
attach vdisk
select disk 1 (the # should be disk# of vdisk)
select part 1
assign letter=O:
exit
-
-
-
- Using imagex.exe/gimagex.exe to apply the captured WIM to O:
- Using diskpart.exe to detach vdisk
-
-
-
-
- Now the C:\VHD\WIN7ENT_BASE.VHD is ready to use.
-
Note: the size of parent disk will be the disk size of child disk, which cannot change any more, please reserve free space for your further modification. For example, I have 12G data on drive C, so I set the fixed size of VHD is 32G. or set it to 127G with expending VHD. BTW, the Disk2VHD utility are not right tool to make VHD boot, it should be use for P2V scenarios, that VHD boot in VPC or Hyper-V.
- Make differential VHD
- Boot into your Win7 on hard disk or WINRE environment on USB/DVD
- Run diskpart.exe in administrator privilege
- Use this command to create multiple VHD
create vdisk file="c:\vhd\win7ent_1.vhd" parent="c:\vhd\win7ent_base.vhd"
- Add new boot entry in BCD
- Run CMD.EXE in administrator privilege
- Use the following command to add new entry
bcdedit /copy {current} /d "Win7 Enterprise VHD1"
command return {guid}
bcdedit /set {guid} osdevice vhd=[c:]\vhd\win7ent_1.vhd
- 3. Repeat to add multiple VHD entry
- 4. Run bcdedit /v to check entry settings
- 5. Run bcdedit /default {guid} to change default entry
- Reboot system and see new boot choices, and select one to boot into VHD
- You can start to use the new VHD boot system.
- Normally the VHD will be [c:], the original [c:], which host VHD file will be [d:].
- The size of D:\VHD\win7ent_1.vhd will be show as the same with its parent disk D:\VHD\win7ent_base.vhd. the actual size can be seen when you boot into original Win7 on hard disk or other VHD system.
Note: If the VHD you boot from the same machine you captured, you make see a strange thing that the VHD becomes the D: drive and you boot from the D: drive, but your original C: drive is still there. It because the VHD are duplicate with physical disk on this machine, it has hardware information of the physical disk.
It's totally messed up, because the registry on the VHD is a clone of the registry on C: drive, and includes many hard-coded references to C:. So %ProgramFiles% is still set to "C:\Program Files\". You can switch the C: and D: by this KB article. https://support.microsoft.com/?kbid=223188
Preference Links:
ImageX GUI utility by autoitscript.com
https://www.autoitscript.com/gimagex/
Demonstration: Windows 7 VHD Boot
How Do I: Windows 7 VHD Boot Demonstration?