How do you mount a VHD?

A VHD (Virtual Hard Disk) is a file format that allows you to mount a virtual hard drive on your computer. Mounting a VHD allows you to access the files and data stored on the virtual drive just like a physical disk. There are a few different ways to mount a VHD file depending on your operating system.

What is a VHD file?

A VHD or Virtual Hard Disk file is a container format for virtual hard drives. It allows you to create a virtual representation of a physical hard drive that can be used by virtualization software like Hyper-V or VirtualBox. VHD files contain a full file system with boot sectors, partition tables, file system metadata, and of course the virtual hard disk data itself.

VHD files come in two main formats:

  • VHD (Virtual Hard Disk) – The original and less efficient format used in Virtual PC.
  • VHDX (Virtual Hard Disk eXtended) – A newer format supported by Hyper-V that supports larger drive sizes up to 64TB.

The most common use case for VHD files is creating disk images for virtual machines. The VHD file acts as a virtual hard drive that the virtual machine can mount and boot from just like a physical disk. This allows you to easily create, manage, and deploy virtual machine disk images.

In addition to virtual machine disk images, VHD files can also be used for:

  • Backups – VHD backups allow you to take snapshots of an entire drive that can be easily restored.
  • Physical to Virtual (P2V) migrations – Migrating a physical server to a virtual machine by creating a VHD backup of the physical disk.
  • Portable virtualized applications – Packaging and distributing a virtualized application inside a VHD file.

Why would you want to mount a VHD file?

There are a few common reasons you may want to mount a VHD virtual disk on your computer:

  • Access files in a virtual machine disk image – Mounting a VHD allows you to access files and data from a virtual machine backup or disk image.
  • Recover data from a backup – Mount a VHD backup to recover previous versions of files or data.
  • Temporarily boot a disk image – Mount and boot a VHD to temporarily simulate a system disk on your physical machine.
  • Edit or modify a disk image – Mount a VHD to make changes before booting it in a virtual machine.
  • Physical to virtual migration – Mount a P2V migrated VHD backup to verify data integrity and migration success.

The main advantage of mounting a VHD instead of just extracting the files is that you see the full disk structure including boot sectors, partition tables, drive volumes, etc. This allows you to access the VHD just like a regular hard disk drive.

How to Mount a VHD file on Windows

There are a couple different ways to mount a VHD file on Windows. The method you use will depend on the Windows version and whether you want a permanent or temporary mount.

Mount VHD using Disk Management

Disk Management can be used to permanently mount and assign a drive letter to a VHD or VHDX virtual disk.

To mount a VHD using Disk Management in Windows:

  1. Open Disk Management (diskmgmt.msc)
  2. Click Action > Attach VHD at the top
  3. Browse to and select your .vhd or .vhdx file
  4. The VHD will show up as an unknown disk in the bottom panel
  5. Right click the disk and select Initialize Disk
  6. Right click the disk again and select New Simple Volume
  7. Walk through the wizard to create a new volume on the VHD
  8. The VHD will now appear as a new disk with drive letter assigned

This mounts the VHD permanently as a disk drive on your system. To remove it, right click on the disk in Disk Management and select Detach VHD.

Mount VHD using DiskPart

DiskPart is another option for permanently mounting a VHD file through the command line.

To mount a VHD with DiskPart:

  1. Open a command prompt as Administrator
  2. Type diskpart and press Enter
  3. Type list vdisk to list the VHD files available to mount
  4. Type select vdisk “file=path\to\file.vhd” using your VHD’s full path
  5. Type attach vdisk to mount and attach the VHD
  6. The VHD will now show up in Disk Management with a drive letter assigned

Use the detach vdisk command to detach the mounted VHD file when no longer needed.

Mount VHDX using PowerShell

For Windows 8 and later, PowerShell provides a quick way to temporarily mount a VHDX, VHD, or ISO disk image.

To mount a VHDX with PowerShell:

  1. Open an elevated PowerShell prompt
  2. Run Mount-DiskImage -ImagePath path\to\file.vhdx
  3. This will mount the VHDX and assign a drive letter
  4. Access the mounted disk through the assigned drive letter
  5. Run Dismount-DiskImage when finished to dismount

Similarly, to mount a VHD or ISO instead of VHDX, use the Mount-VHD or Mount-ISO cmdlets.

Mount VHD using File Explorer

You can also mount a VHD or VHDX by right clicking on it in Windows File Explorer and selecting “Mount”. This provides a quick temporary mount that is automatically dismounted when File Explorer is closed.

To mount using File Explorer:

  1. Open File Explorer and navigate to the VHDX or VHD file
  2. Right click on the file and select Mount from the menu
  3. An autoplay window will appear for the mounted virtual disk
  4. Access files on the mounted disk through the autoplay window
  5. Dismounting occurs automatically when File Explorer is closed

Mount a VHD at boot

You can also set up a VHD to automatically mount during boot in Windows. This allows you to boot from a VHDX like an internal system drive.

To auto-mount a VHDX for booting:

  1. Open Regedit and navigate to HKLM\SYSTEM\MountedDevices
  2. Create a new key named \DosDevices\X: where X: is your desired drive letter
  3. Set the (Default) value to \??\Volume{GUID}\path\to\file.vhdx
  4. Reboot and the VHDX will mount on boot with the specified drive letter

How to mount and unmount a VHD on Linux

On Linux systems, you can use either the mount command or Virt Manager GUI to mount a VHD file.

Mount VHD using mount command

To manually mount a VHD file using the mount command:

  1. Create a mount point folder: sudo mkdir /mnt/virtual
  2. Mount the VHD file: sudo mount -t auto -o loop disk.vhd /mnt/virtual
  3. Access the VHD files under the /mnt/virtual mount point directory
  4. Unmount with: sudo umount /mnt/virtual

The auto filesystem type will auto-detect the filesystem inside the VHD. You can also specify a filesystem type like ntfs if known.

Mount VHD using Virt Manager

If you have the Virt Manager GUI installed, you can use it to mount VHD images:

  1. Open Virt Manager and click File > Add Connection
  2. Choose Storage file rather than hypervisor
  3. Browse to and select your VHD or VHDX file
  4. Click Finish to add the virtual disk
  5. Right click on the disk and select Details to view files

This mounts the disk so you can view and access files through Virt Manager. Click Remove when finished.

How to mount a VHDX file on Mac

Macs don’t include native support for mounting VHDX or VHD disk images. But there are a couple third party tools available for mounting Windows virtual disks on Mac.

Mounty for Mac

Mounty for Mac is a free utility for mounting disk images including VHD, VMDK, and IMG files.

To mount a VHDX on Mac with Mounty:

  1. Download and install Mounty
  2. Right click on the VHDX file and choose “Mount” to mount
  3. Access the files in Finder under /Volumes
  4. Right click and select Unmount when finished

Paragon VHD Mounter

Paragon VHD Mounter is a paid utility that allows mounting VHD and VHDX files on Mac with additional features like encryption and compression.

To use Paragon VHD Mounter:

  1. Download and install Paragon VHD Mounter
  2. Double click on a VHDX file to automatically mount it
  3. The virtual disk will appear on the desktop and in Finder
  4. Click the eject icon to unmount the disk image

Conclusion

Mounting a VHD virtual disk allows you to access and view files from a VHD image like a regular drive. On Windows, options include Disk Management, DiskPart, PowerShell, and File Explorer. On Linux the mount command or Virt Manager can be used. And Mac users can utilize tools like Mounty or Paragon VHD Mounter to mount Windows VHDX files.

Reasons for mounting a VHD include accessing files in virtual machine images, recovering data from backups, migration testing, and modifying images offline. Mounting virtual disks instead of extracting files has the advantage of maintaining the full disk structure including partitions and boot data.