Restoring Thin-Provisioned VHD Exports to Microsoft Hyper-V

Topic

This article describes the process for attaching a VHD export to a Windows host as a mounted volume and exporting its data to a thin-provisioned Microsoft Hyper-V virtual drive.

To restore a VHD to Microsoft Hyper-V with thick provisioning, see Restoring Thick-Provisioned VHD Exports to Hyper-V.

Environment

  • Datto SIRIS
  • Datto ALTO
  • Microsoft Hyper-V
  • Windows Server 2008
  • Windows Server 2008 R2
  • Windows Server 2012
  • Windows Server 2012 R2
  • Windows Server 2016
  • Windows Server 2019
  • Windows Server 2022

Description

This article provides two methods for restoring thin-provisioned VHD exports. The Alternate method listed second is not compatible with Microsoft Windows 2019 & 2022, but we have included it as an alternative that you can use with other Windows versions if desired.

During this process, you will mount a restore, create a new, dynamically-allocated virtual volume in Hyper-V, and then copy the contents of the exported VHD to the new volume.

This article uses screenshots that may vary depending on the platforms and versions being used.

Follow the steps outlined below.

  1. Mount an image export on your Datto device by following the steps in the Exporting to a Network Share section of the Export Image article. Make a note of the CIFS/Samba VHD Share path your appliance provides once the restore is mounted.
  2. Launch Hyper-V Manager from Start > Administrative Tools > Hyper-V Manager.
  3. From Hyper-V Manager, click Action > New > Hard Disk.


Figure 1: New Hard Disk

  1. If you see a Before You Begin dialog, click Next.
  2. Select the destination disk format and then click Next.


Figure 2: Choose Disk Format

If you are unsure whether you should create a VHD or VHDX Image Export, refer to this Microsoft article(external link) for OS compatibility.

  1. Choose the destination Disk Type, and then click Next.


Figure 3: Choose Disk Type

  1. Specify a name for the virtual disk and the location to save it to, and then click Next.


Figure 4: Specify Name and Location

  1. Select the disk or disks to copy by clicking Copy the contents of the specified virtual hard disk and browsing to the CIFS/Samba VHD Share path your appliance provided in step 1, then select the image file. Repeat these steps for all volumes that you need to restore.

NOTE   If you recieve an error when attempting to access the share path, it may be due to Windows security policy settings for SMB. You may need to adjust group policy settings. See Guest access in SMB2 and SMB3 disabled by default in Windows (external link)


Figure 5: Select the specified virtual hard disk

  1. Review the summary to ensure that the virtual hard disk is configured correctly. When you are ready to proceed with disk creation, click Finish.


Figure 6: Summary

  1. A progress bar showing the status of the transfer will appear.


Figure 7: Creating the new virtual hard disk

Alternate method

NOTE  This alternate method will not work on Server 2019 & 2022 hosts and could result in Incorrect function (0xc8007001) errors on Windows 2019 & 2022 systems.

Index

Part 1: Attaching the Volume as a Logical Drive

  1. Before proceeding further, mount an image export on your Datto device by following the steps in the Exporting to a Network Share section of the Export Image article. Make a note of the CIFS/Samba VHD Share path your appliance provides once the restore is mounted.
  2. Launch Disk Management on your Hyper-V-enabled Windows machine.


Figure 8: Launching Disk Management

  1. Click Action > Attach VHD.


Figure 9: Attach VHD

  1. At the Attach Virtual Hard Disk prompt, select Browse.


Figure 10: Attach Virtual Hard Disk

  1. In the Location field, enter the CIFS/Samba VHD Share you obtained in Step 1. Then, click Open.
  2. When the share opens, select the hard disk image, and click Open.


Figure 11: Selecting a hard disk image

If boot.vhd and C.vhd are both present, select boot.vhd as the first drive, and attach C.vhd as the secondary drive. If only C.vhd is present, use C.vhd as the first drive.

NOTE  For Linux systems, C.vhd will be sda1.vhd.

There are two reasons to add a boot and a C volume:

  • For devices where UEFI is unsupported, adding a boot and C:\ volume is necessary to make GPT-formatted OS volumes readable.
  • Adding both volumes fixes virtualization failures for some MBR / BIOS agents. While a production Windows machine can still boot from its System Reserved partition even if its NTFS bootstrap code has corruption, virtualizations do not have this ability unless both the boot and C volumes are present.
  1. At the Attach Virtual Hard Disk prompt, check the Read-only box, and click OK to mount the image.


Figure 12: Attach Virtual Hard Disk

  1. The VHD will mount as a volume in Windows.


Figure 13: VHD attached as Windows volume

  1. To recover files from the virtual disk with their permissions intact, use Robocopy or Richcopy.
  2. To import the disk image into Hyper-V, see the next section of this article.

Part 2: Importing the Volume into Hyper-V Manager

  1. Launch Hyper-V Manager from Start > Administrative Tools > Hyper-V Manager.
  2. From Hyper-V Manager, click Action > New Hard Disk.


Figure 14: VHD attached as Windows volume

  1. If you see a Before You Begin dialog, click Next.
  2. Select the destination Disk Format, and then click Next.


Figure 15: Choose Disk Format

  1. Choose the destination Disk Type, and then click Next.


Figure 16: Choose Disk Format

  1. Specify a name for the virtual disk and the location to save it to, and then click Next.


Figure 17: Specify Name and Location

  1. Select the disk or disks to copy by clicking Copy the contents of the specified physical disk and selecting the PHYSICALDRIVE value that is the same disk number as the VHD that is mounted. Then, click Next. Repeat this step for all disks involved in the restoration.


Figure 18: Disk number of mounted VHD


Figure 19: Physical Hard Disk path

  1. Review the summary to ensure that the virtual hard disk is configured correctly. When you are ready to proceed with disk creation, click Finish.


Figure 20: Summary

  1. A progress bar showing the status of the transfer will appear.


Figure 21: Creating the new virtual hard disk

  1. After the transfer has completed, detach the VHD from Disk Management.


Figure 22: Detach VHD

Part 3: Finalizing the Restore

  1. From Hyper-V Manager, click Action > New > Virtual Machine. When the New Virtual Machine Wizard launches, click Next.
  2. If the Before You Begin page pops up, click Next.
  3. Provide a name and (optionally) a storage location for the virtual machine, and then click Next.


Figure 23: Specify Name and Location

  1. Specify the Generation of the VM. If you are using Hyper-V Manager 2008 or earlier, skip this step. Your Hyper-V Manager environment does not support Generation 2 virtual machines.

Generation 1 provides the same virtual hardware to the virtual machine as previous versions of Hyper-V. Any virtual machine over 2 TB must use a Generation 2 template.

Generation 1 VMs:

  • Can use VHD and VHDx disk formats
  • Only support the MBR boot type

Generation 2 provides support for features such as Secure Boot, SCSI boot, and PXE boot using a standard network adapter. Guest operating systems must be running at least Windows Server 2012 or 64-bit versions of Windows 8.

Generation 2 VMs:

  • Can only use the VHDx disk format
  • Only support UEFI; BIOS is unsupported
  1. Provide the amount of RAM to allocate the virtual machine. Then, click Next.
  2. Select the NIC to use in the virtual machine. The default value is Not Connected (Hyper-V Manager 2008 or earlier) or None(Hyper-V Manager 2012).
  3. On the Connect Virtual Hard Disk page, select Use an existing virtual hard disk. Provide the path to the datastore where you copied the VHD(x), and then click Next.

NOTE   Be sure to attach boot.vhd(x) first.

  1. On the Summary page, confirm all configuration settings are correct and click Finish.
  2. In the Virtual Machines pane, right-click the VM, and then click Settings.
  3. Click the storage controller to which you attached boot.vhd(x). Then, click Hard Drive > Add.


Figure 24: Hard Drive

  1. Select Virtual hard disk if it is not already selected. Browse to the location of your C.vhd(x) (or sda1.vhd, on Linux systems), select it, and click Apply. Repeat this step for each additional disk that you need to attach.


Figure 25: Browsing to and selecting a virtual hard disk

  1. When you finish configuring the virtual machine's settings, click OK, right-click the VM, and click Start.

If the VM boots, the restore is complete.

If the VM fails to boot:

  • Collect and research any errors thrown, if applicable
  • Ensure that the VM uses the right Generation and disk format for its boot type. Remember: MBR = Generation 1, GPT = Generation 2.
  • Contact Datto Technical Support if you continue to experience bootability issues.


Figure 26: Starting the VM

Additional Resources