VHD to Disk

How to Convert a Virtual Machine VHD to a physical disk

Restore PC From a VHD File
Restore VHD file to a new physical hard drive.
This procedure will work for Windows 7 and Windows Server 2008 R2 operating systems. The scenario is you installed Win7/WS2K8R2 using a VHD file. You have a copy of the VHD file or can make a copy. Now you find yourself with a new hard drive (old drive failed, new larger drive, new computer, etc.). How do you migrate that VHD file over to the new hard disk? If your old drive is still usable, you should SYSPREP the installed OS and store the resultant VHD file on an external USB drive or network share.
To prepare the new hard drive, follow this procedure:
1. Boot from Win7/WS2K8R2 PE or Installation DVD on new Bare Metal PC. At the opening installer screen, open a command window by pressing Shift+F10 and run the following commands. You should be on the X: drive.
2. Partition and Format the new PC's hard drive:
list disk
select disk <disk_number_to_format>
clean (be careful, this removes all volumes, partitions and data)
create partition primary
format quick fs=ntfs label="(any name you wish)"
assign letter=c
3. Copy your sysprepped Win7/Windows Server 2008 R2 VHD file from the source USB drive or Network
drive to the new partition:
net use n: \\your_server\share_folder\
md c:\R2 (or c:\Win7)
copy n:\Win7\win7.vhd c:\Win7\
4. Attach the VHD on the new PC:
select vdisk file=C:\Win7\windows7.vhd
attach vdisk
list volume
select volume <volume number of attached VHD>
assign letter=v
5. Copy boot environment and configuration files from the VHD to the
new partition:
cd v:\windows\system32
bootsect /nt60 c: /force /mbr
bcdboot v:\windows /s c:
bcdedit /store c:\boot\bcd /copy {default} /d "Windows7 VHD boot (locate)"
Insert below the {new_guid} from the above BCD entry copy:
bcdedit /store c:\boot\bcd /set {new_guid} device vhd=[locate]\windows7.vhd
bcdedit /store c:\boot\bcd /set {new_guid} osdevice vhd=[locate]\windows7.vhd
bcdedit /store c:\boot\bcd /default {new_guid}
bcdedit /store c:\boot\bcd /set {new_guid} detecthal on
That's it, remove any media from the dvd drive and reboot. The system will go through hardware detection and you will have a freshly installed OS, using a VHD file as the source.

© Willi Neuner 2019 Impressum