Create a Virtual Hard Disk (VHD)

With the advent of Windows Vista and Windows 7, Microsoft has been delving ever deeper into the realm of “virtual computing.”    Part of that is the creation of something called a Virtual Hard Disk.  This is a pretty neat concept that I think has a lot of possibilities at work or at home.

What is a Virtual Hard Disk?

A Virtual Hard Disk (VHD) is essentially one single large file that contains all the files and folders that make up one entire hard drive.  You can create, delete, mount, partition, label, and assign drive letters to a VHD just like you could with a real physical hard drive.  The added benefit of a VHD is that you can easily make copies of your whole drive, and share it with others, or use one copy as a backup while you work with another copy.  Anything you can do with a real (physical) hard drive, you can do with a VHD (yes, you can even boot a PC from a VHD).  As you can image, there are many possibilities here.

So How Do I Make One?

Now, before we create a VHD, you need to know that there are three types of VHDs you can create:

  • Fixed VHD: a VHD that is initially set up to be a certain size, and the actual VHD file will always be that size.  This is the “default” type of VHD and the type that Microsoft recommends you create in most cases.
  • Dynamic VHD: a VHD that is set up to go up to a certain size, and the actual VHD file will be whatever size is equal to the amount of data in the VHD.  You can also set a maximum size limit for this type of VHD.  While this type of VHD may sound good (since the VHD file will only be as big as the amount of data on the VHD), you should know that the data transfer rates on this VHD are not as good as on a Fixed VHD.  Also, you run the risk of “running out of disk space” while using this type of VHD if the physical hard drive runs out of space.
  • Differencing VHD: a special type of VHD that is set up as a child VHD to a separate parent VHD.  This VHD only contains data that is different from the parent VHD.  This one is really only used by developers and those who like to test and destroy operating systems. 🙂

VHDs can only be created and used via the method I’m about to explain in Windows 7 Enterprise edition or Ultimate edition (sorry all of you Home Premium users) or in Windows Server 2008 R2.  That’s not to say that other versions of Windows 7 or Vista or XP can’t use VHDs – they can, but require a program like Windows Virtual PC or Microsoft Virtual Server (and the use of these programs isn’t something I’m going to cover here).

There are a couple of ways to create a VHD, but the simplest way to create an empty VHD is to use the Windows Disk Management snap-in.  To open that utility up, go into your Start menu and right-click on Computer then choose Manage.  This brings up the Computer Management Console.  Once that’s up, click on Disk Management on the left panel.  Now if you look at the center pane, you will see all the hard drives installed on your system.  And this is also where we can create and modify a VHD.  So with that said, here’s how to create a Fixed VHD:

  1. In the Disk Management application, right-click on Disk Management in the left panel and choose Create VHD.
  2. A dialogue box will pop up.  In the Location field, type in a full drive, path and filename for the VHD file that you want to create.  Be sure you end the filename with a .vhd file extension.  (Tip: you could save this file to a USB flash drive to make portability even easier)  Then in the Virtual hard disk size box, type in the size of the drive that you want to create, then choose MB (megabytes), GB (gigabytes), or TB (terabytes) from the drop down.  Finally under Virtual hard disk format, just leave the selection at Fixed size.  Once you’ve filled this out, the box should look something like this:
  3. Hit the OK button and in a matter of minutes (or longer depending on the size of the VHD you created) you’ll be back at the Disk Management pane and be able to see your newly created Virtual Hard Disk in the center panel.  It’s almost as if you opened up your computer and plugged in a new hard drive (except of course this one doesn’t give you any extra space since it’s “Virtual”)!
  4. Before you can partition, format and play around with the disk, you need initialize it.  As you can see in the image above, the disk says Not Initialized.  We need to initialize it, so, right-click on Not Initialized and choose Initialize Disk.  You’ll get this dialogue box:
  5. Here’s the easy part – just click OK.  The default settings here are good.  At this point, the Not Initialized should now say Online.  Now you are ready to partition, format, and assign a drive letter and maybe a volume name to the VHD.  Have fun!

    What’s that?  You say you don’t know how to partition, format, and assign a drive letter to a drive?  Oh.  I see.  In that case, I’ll continue on…

  6. Let’s partition, format and assign a drive letter all in one shot: right-click on the rectangle that says Unallocated and choose New Simple Volume. If you do that you’ll get the New Simple Volume Wizard.  Essentially you will want to just click Next four times and then click Finish – just go ahead and accept all the default settings that this wizard gives you.  One thing you might want to take note of during the wizard is what drive letter you want to assign the drive – you can change it or leave it as is depending on what you want that to be.  After clicking Finish you will have a newly partitioned and formatted Virtual Hard Disk, ready for business.  Wonderful.

Sharing is Caring

Okay, so let’s say you filled your VHD up with all sorts of good stuff and now you want to share it with the world.  Great.  That’s what VHDs are good for.  But before you can let your buddy in Montana use your VHD, you need to “detach” it from your PC.

Now if this was a physical hard drive, you’d need to shut down the PC, open up the case and unplug the drive from the motherboard and power, then button things back up.  But since you’re working with a Virtual Hard Disk, there are no annoying physical tasks to do here.  All you need to do is go back into that Disk Management console (see above if you’ve already forgotten how to), find the VHD, right-click on the box that says Disk x (where x is the Disk number), then choose Detach VHD. Once you do that you’ll get a box that reminds you that you are about to detach a VHD, along with a handy option to actually delete the .vhd file off the hard drive (if that’s what you want to do).


I’m assuming that you want to keep the .vhd file so that your buddy in Montana can use it, so, leave the Delete the virtual hard disk file after removing the disk box unchecked and just hit OK here.  Bam.  Now you can copy that VHD file over to a USB Flash drive, or share it across your company network.

Once your buddy receives the VHD file, all he needs to do is “attach” it to his machine like so: go back into that Disk Management console, right-click on Disk Management in the left pane, choose Attach VHD, type in the drive, path and filename of the .vhd file (or click Browse…), then hit OK.  Boom.  Now he can look at your VHD with all the data (or lack thereof) that it contains.

Final Thoughts

Remember these points for VHD fun and success:

  • In order to view/modify the data on a VHD, you must first “attach” it to your machine, then navigate to its drive letter in Windows Explorer.
  • In order to share/copy/move/delete the actual .vhd file, you must first “detach” it from your machine, otherwise Windows will tell you that the file is in use and cannot be changed.  Likewise, if you’re running your VHD file off of a USB flash drive, remember to “detach” it before you unplug your USB flash drive from your machine.
  • VHD files are usually very large and with lots of “shipping and handling” could possibly get corrupt and therefore unusable.  While this isn’t real likely, Microsoft still recommends that you not keep “mission critical” files on a VHD.
  • Remember – the process I’ve outlined above will only work on Windows 7 Enterprise edition or Ultimate edition or Windows Server 2008 R2.  However, you can view and modify VHDs with other (and older) Windows operating systems by using the Windows Virtual PC application (which is a free download from Microsoft).

In a future post, I’ll explain how to create a bootable VHD and then set your PC up to boot from it (or dual-boot, if you have more than one).  Until then, have fun!

Leave a comment