5

I have read other question/answers on this site that say this is possible, but I'm wondering how it is done. I have tried the following command, which completes successfully, but the NTFS isn't valid on the drive afterwards.

$ dd if=\backup\image.vhd of=\dev\sda

Does the .vhd file have to be mounted somehow first? Will this restore the MBR?

Thank you.

Reference Question

2 Answers 2

7

The VHD file isn't a raw image format (like DD uses), so you will have to use something to convert it to a raw format.

Looking at the VBoxManage webpage the following command should work, but I haven't tried it:

$ VBoxManage clonehd /backup/image.vhd - --format RAW | dd of=/dev/sda

As I say I haven't tried it, but you could read up on VBoxManage at the VirtualBox website:

1
  • I get error: unknown option: - using version 7.0.12. I looks like clonehd is now an alias of clonemedium
    – Brandon
    Dec 25, 2023 at 23:59
1

For later reference, I had the following issue:

  • DELL Precision 390 with Linux/Debian wheezy installed (X86_64)
  • A VHDX backup of the pre-installed Windows XP 64bits (see disk2vhd)
  • A BKF backup of all the files using the default NTBackup program
  • No Windows XP 64bits rescue disk

My issue was to reset the system back to Windows XP 64bits.

Attempts:

  • I did not understand a word of the solution described here, but I am mostly a UNIX guy. The following link did not make much sense either.

  • There were a couple of solutions described from a Windows 8 installation, but I had no Windows 8 disk for testing.

  • I re-installed Windows XP 32bits (I had a spare disk), but I was not sure if I could use the BKF file to overwrite an existing Windows XP 32bits with the files contained in the BKF file.

  • After reading information from this link:

Note: Use the Recovery Environment for Windows to restore from a VHD/VHDX formatted image file. The Recorvery Environment CrossPlatform only supports restores from .SPF and .SPI image files, not from VHD or VHDX format files.

  • I used a Windows 7 32bits Windows Recovery Environment disk, click on "Windows Complete PC Restore". After an insane amount of trials I could never get this tool to see neither the BKF, the VHDX nor the VHD (converted using VBoxManage). I tried using a shared network drive, I could hear the disk spinning but the drive would file would never show up on the interface, I even tried from a USB key, but again the tool would not let me pick the USB key option (I do not want to use the DVD drive option since I had no RW+ DVD around). VBoxManage really does support VHDX file, even if this is not mentioned in the documentation, as per link.

I was about to give up until, I found this post, and I can happily report that this is working nicely for me.

Steps were as easy as:

  • Open the DELL Precision 390 case, remove the hard drive
  • Plug it into a Debian Jessie (x86_64) system
  • Use gnome-disks to clear up the disk partitions, just click the "-" (minus) sign, write down the /dev/sd[Letter] somewhere (sdf in my case), double check that the disk is not mounted,
  • Run the following command VBoxManage clonehd windows_xp64.VHDX --format RAW windows_xp64.RAW
  • Run sudo dd if=windows_xp64.RAW of=/dev/sdf

dd eventually displays:

dd: writing to ‘/dev/sdf’: No space left on device
488281251+0 records in
488281250+0 records out
250000000000 bytes (250 GB) copied, 32825.4 s, 7.6 MB/s

Indeed looking at the file:

$ ls -al windows_xp64.RAW
-rw------- 1 mathieu mathieu 250000048128 Dec 11 20:02 windows_xp64.RAW

I figured this could be discarded since the last 48128 bytes were all zeroes, I am not sure where those extra bytes came from (disk2vhd or VBoxManage...).

I had to use a two (very slow) steps approach, because VBoxManage does not pipe to stdout, at least from my debian jessie installation,

$ apt-cache policy virtualbox
virtualbox:
  Installed: 4.3.18-dfsg-1
  Candidate: 4.3.18-dfsg-1
  Version table:
 *** 4.3.18-dfsg-1 0
        500 http://ftp.fr.debian.org/debian/ jessie/contrib amd64 Packages
        100 /var/lib/dpkg/status

It seems to still be an issue upstream, as per Enable writing to STDOUT with VBoxManage clonehd in raw format.

There might have been an easier solution using the BKF file but I never found out one for sure.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .