Mounting VHDs with Windows 7

Mounting VHDs with Windows 7

  • Comments 11

In Windows 7 / Windows Server 2008 R2 VHD support is now part of the platform.  This means that you do not need to enable Hyper-V to mount and manipulate virtual hard disks.  You can mount virtual hard disks directly on your Windows 7 / Windows Server 2008 R2 system in two ways.  The first is to use the Disk Management UI:

  1. Open the Start menu
  2. Right click on Computer and select Manage
  3. Expand Storage and click on Disk Management
  4. Click on the Action menu and select Attach VHD
  5. Enter the Location and name of you virtual hard disk (there is a browse button you can use)
  6. Click OK

And you are done - simple!  To unmount the virtual hard disk you just need to right click on Disk entry for the virtual hard disk and select Detach VHD.

The other option is to use diskpart.  To do this you will need to:

  1. Open up an administrative command prompt.
  2. Run diskpart
  3. Type in SELECT VDISK FILE=insert your VHD file path and name here
  4. Type in ATTACH VDISK

When you are done you can unmount the VHD using the DETACH VDISK command under diskpart.

Cheers,
Ben

Leave a Comment
  • Please add 6 and 5 and type the answer here:
  • Post
  • Can you boot to the VHD? Or do you need to install Virtual PC to run the image?

  • You can boot from the VHD, though I haven't tried it myself but have heard it more than once in the videos.

  • Do you know how to boot from the VHD?

  • It'd be nice if you added support for mounting ISO files in the same way.

  • It's great that VHD mounting is built-in.  It's unfortunate that it requires more clicks than the old registry hack from Virtual Server 2005.  We really ought to have right-click support in Explorer.

    As with the rest of the Disk Management UI that'll never see a refresh, I fear we will be stuck with this limitation for the next twenty years.  Although Microsoft is spending more effort on fit-and-finish these days, this sadly does not extend to management tools that ordinary users won't ever see.  (I mean, geez, how many clicks does it take to change a drive letter?)

  • Check out a few posts on my blog on how to create VHD boot

    http://www.ravichaganti.com/blog/?p=333

    http://www.ravichaganti.com/blog/?p=317

  • @Tom

    I agree that it takes more clicks to attach / detach a VHD using MMC. However, you can very easily add that right click / explorer functionality. Check out http://www.ravichaganti.com/blog/?p=349

  • Alan Dean -

    Yes, you can boot off them.  I am plannig to blog about that at some point in the future.

    Timothy Fries -

    Yes, I agree.

    Tom / Ravikanth -

    You can also still use the Hyper-V APIs to mount VHDs if you are running Windows Server.

    Cheers,

    Ben

  • It works on Windows 7 32-bit, but unfortunately, it does not work on Windows 7 x64. I tried it on two different computers with very fresh installations of Windows 7 Ultimate x64: an attempt to mount a VHD file via Disk Management console results in the error message: "A Virtual Disk Provider for the specified file was not found." Google returns the following article for this error: support.microsoft.com/.../2013544 However, it applies to Windows 2008 Server, not to Windows 7. I tried the registry fix it suggested anyway, but it made no difference. Does anyone know how to solve this problem? Thanks.

  • What if I want todo the reverse - map a host directory to a drive in the VM? I am sure I could do this in VM 2007 but cannot find how to do this in the new VM.

  • Andrei Belogortseff -

    I have it working on two x64 Windows 7 computers, so I do not know why it is not working for you.

    Adrian Tawse -

    You need to use disk sharing.  Some details are here: blogs.msdn.com/.../accessing-shared-drives-from-the-command-prompt-under-windows-virtual-pc.aspx

    Cheers,

    Ben

Page 1 of 1 (11 items)