How can I copy a VHD image back to a physical disc?

132,914

Solution 1

You can use qemu-nbd in Linux to access a disk image as if it were a block device.

Here are some examples of operations that can be performed from a live Knoppix terminal.

  su 
  modprobe nbd
  qemu-nbd --read-only --connect=/dev/nbd0 --format=vpc <vhd_file_name>

If VHDX format:

  qemu-nbd --connect=/dev/nbd0 --format=VHDX <vhdx_file_name>
  ddrescue --verbose --force /dev/nbd0 /dev/sda  # write image to /dev/sda

Write one partition:

  qemu-nbd --partition=2 --read-only --connect=/dev/nbd2 --format=vpc <vhd_file_name> 
  ddrescue --verbose --force /dev/nbd2 /dev/sda2 # write partition 2 of image to /dev/sda2

Mount partition:

  qemu-nbd --partition=2 --read-only --connect=/dev/nbd2 --format=vpc <vhd_file_name>
  mount /dev/nbd2 /mnt 

Unmount and disconnect image file:

  unmount /mnt 
  qemu-nbd --disconnect /dev/nbd2

Solution 2

There are at least two similar questions that got accepted answers:

https://superuser.com/questions/40294/copying-a-vhd-to-a-physical-disk

Vdisk (vhd) to physical

But you can't do it from a running OS.

It would be a hard thing to script this. Following the Linux dd aproach one could say that everything is possible. Boot from PXE, locate the VHD, locate the physical disc, dd from V to P, when finished reboot.

Solution 3

Use HDDGuru Raw Copy Tool

  1. Mount the VHD(X) using explorer on Windows 8/10
  2. Plug in the target disk
  3. Use the Raw Copy tool to copy the mounted disk to target physical disk

This can be used for any of the mountable formats on Windows, iso, vhd, vhdx etc.

Solution 4

It is possible to use Virtualbox to attach a physical device as a virtual device inside the VM

Windows method

VBoxManage internalcommands createrawvmdk -filename "C:\Users\vhudson\VirtualBox VMs\usb.vmdk" -rawdisk \\.\PhysicalDrive1

Linux method

VBoxManage internalcommands createrawvmdk -filename usb.vmdk -rawdisk /deb/sdb

Using an additional iso as live CD something like hirens boot or some linux rescue image, it is also possible to do image copying from one virtual device to a physical device that is virtually present inside the virtual machine.

Solution 5

I have used vmdk2phys to successfully accomplish this.

There's another tool called Disk Image Tools or DITOOLS, which purports to do the same.

As others have stated, acronis true image can do this. Western Digital has a version of acronis true image that works on any computer with at least one WD hard drive installed called Acronis True Image WD Edition, however I am unsure if it supports Virtual Machine Hard Disk Images such as VHD/VMDK.

Another option is to mount the vhd in the Disk Management MMC, and then use a tool such as Roadkil RawCopy.

Share:
132,914

Related videos on Youtube

Christian
Author by

Christian

Updated on September 18, 2022

Comments

  • Christian
    Christian almost 2 years

    It's quite easy to backup a real drive to VHD, e.g. with Sysinternal's Disk2VHD on XP or with Windows Image Backup on Windows 7. But how do I copy that file back?

    It's possible by booting a recovery CD or the Windows installation DVD. But can it also be done from a running operation system? Can it be scripted?

    We want to clone a drive to another drive daily using this.

    • mailq
      mailq almost 13 years
      You just want to use the VHD as an exchange format? Without ever running it in a virtual machine? Then use imaging software like Clonezilla, Norton Ghost or Acronis True Image.
    • Christian
      Christian almost 13 years
      Microsoft chose VHD as it's image format for any kind of activity: They use it for backups and in Win 7 you can mount them directly. The question how to RESTORE a backup is surely okay!
  • Vouze
    Vouze almost 9 years
  • user66001
    user66001 almost 8 years
    Think the OP needs steps of how to use bcdedit, and how to "paste your vhd file on c:".
  • Suncatcher
    Suncatcher about 5 years
    Can single partition be selected in Raw Copy Tool as target? I see it allows only overwriting the whole disk
  • Suncatcher
    Suncatcher about 5 years
    As it seen from DITOOLS description it supports only disk-to-image conversion, not vice versa