Freigeben über


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:

  1. Prepare VHD 
    1. Method 1
    1. 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
        1. Boot by Win7 DVD/USB click repair mode or boot into WinRE/WinPE
        2. 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.
        3. 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

        1. Using imagex.exe/gimagex.exe to apply the captured WIM to O:
        2. 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.

 

  1. Make differential VHD
    1. Boot into your Win7 on hard disk or WINRE environment on USB/DVD
    2. Run diskpart.exe in administrator privilege
    3. Use this command to create multiple VHD

create vdisk file="c:\vhd\win7ent_1.vhd" parent="c:\vhd\win7ent_base.vhd"

  1. Add new boot entry in BCD
    1. Run CMD.EXE in administrator privilege
    2. 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
  1. Reboot system and see new boot choices, and select one to boot into VHD
  2. You can start to use the new VHD boot system.
    1. Normally the VHD will be [c:], the original [c:], which host VHD file will be [d:].
    2. 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

https://www.microsoft.com/downloads/details.aspx?familyid=80EDE31D-3509-407B-A896-0BEEA8705589&displaylang=en

 

How Do I: Windows 7 VHD Boot Demonstration?

https://technet.microsoft.com/en-us/windows/dd758779.aspx