Fun with VHDs

Looking around I found that VHD support is quite extensive inside Win7 but I didn’t realize how much. I also found a few commands that you can run at the cmd prompt to help with VHDs.


First thing I found was that creating a VHD was very easy. You can use the Computer Management console to create a VHD using the GUI. Simply right click on Disk Management and the Create VHD menu item should be there. Clicking on it starts the dialog windows that will help you create a fixed or dynamic VHD.


For those of you who yearn for the days of DOS, you can also use a command at the cmd prompt. Go to an administrative command prompt and enter Diskpart. Diskpart is not just for VHD’s so be careful, you could do some damage to the partitions on your hard drive. Once you’ve started Diskpart, you can create a VHD by issuing the Create command – Create vdisk file=”drive:vhdame.VHD” maximum=max size of vhd type=expandable|fixed


This will create a VHD on the drive you specify with the name you specify – in the example above, I’ve created a VHD called blog.vhd on the D: drive. The maximum tells the system the maximum size of the drive in MB and the type lets you create an expandable or fixed size VHD.

Using the Diskpart command you can automate creation of VHDs if you need to. The VHD will be uninitialized and unattached.


Attaching a VHD lets you use it like a normal hard drive on your system. You can again right on Disk management inside Computer Management and select Attach VHD. You can enter the location and name of the VHD you want to attach or browse for it. If the VHD has been initialized and formatted it will be assigned a drive letter. Otherwise you will have to initialize the VHD and format it.

You can use the Diskpart command to attach a virtual disk. You first have to use the Select command to select the VHD then you can attach the vdisk

Select vdisk file=drive:vhdname.VHD
Attach vdisk

Once the VHD is attached it will show up in Computer Management.

But there’s more…

Attaching and creating VHD’s was what I was expecting, but I didn’t realize you could install an OS to a VHD without using Windows Virtual PC. You can even install a 64bit OS to a VHD. The trick is to use the Diskpart command when installing the OS. lets say you want to create a bootable VHD – one that you could use to boot your physical machine. We’ll assume you have Windows 7 installed on your computer first. Now put in the DVD of the OS that you want to put on your VHD and boot from the DVD. When windows gets to the first screen you can drop to a command prompt (using Shift-F10) and use the Diskpart commands to create and attach a VHD. Once you’ve done this you can exit the command prompt and continue with the installation. When it gets to the part where you are asked to choose where to install the OS you will see an entry for your VHD. Select it (you will get a message saying it can’t install but ignore it) and continue with the installation.

Once the OS is installed you will have a multi-boot system. The first entry in your multi-boot menu will be the OS on the VHD. If you want to change the menu or add a preexisting VHD to your boot menu you can use the BCDEdit command..yes another command prompt command.  BCDEdit lets you modify what shows in your boot menu and also allows you to rearrange things if you want. 

If you have a VHD that is bootable, you can use the BCDEdit command to install it into your boot menu. Unlike Diskpart, BCDedit is a run and done type command (like DIR). Running BCDedit by itself will present you with a list of your current boot menu and the type and location of the OSs you have on your system. The easiest way to add a new entry you in your boot menu is to copy an existing entry. When you copy an entry BCDEdit will create a new entry with a GUID. You use the assigned GUID to modify the new entry to point it to your VHD. Use the Set option to point the OSDEVICE to your VHD. The command would look something like:
BCDEDIT /set {guid} osdevice vhd=[d:]\blog.vhd

You can get help with BCDEdit by passing in /? as the first parameter.

There is another way to work with your boot menu. You can use the MSCONFIG command. This will not give you all the options that BCDEdit will but you can select a default OS from this menu. One thing I’ve learned is that you should not go into MSCONFIG when you have booted into the VHD. Every time I used MSCONFIG when booted into the VHD the system had problems booting back into my main OS. 


7 Responses to Fun with VHDs

  1. Unknown says:


  2. Ron says:

    Hi Rob, Just came across this Blog. I was going to ask you about VHD\’s at the PACS meeting tomorrow; but, in case you haven\’t heard yet, the meeting has been cancelled due to snow.Anyway, I\’m having some trouble with my backups using a USB external drive and figured I\’d create a partition on my internal c drive so I could at least have a temporary backup in case my USB drive failed. Using the Windows 7 Disk Management tool I saw the VHD option. My question is whether a new partition is better or worse than a VHD. What are the advantages and disadvantages of each. Certainly being able to boot from a VHD would be an advantage.Also, looking for a better way to backup, I came across software. They also offer a free Disk Partition management program which has alot more features than Windows 7. Are you familiar with this program?Last Question- Would you like this Blog to be announced on your Windows SIG Forum?Regards,Ron K

  3. Lilliana says:

    Does your blog have a contact page? I’m having trouble locating it but, I’d like
    to sennd yoou an e-mail. I’ve got some creative ideas for your
    blog you might be interested in hearing. Either way, great blog and I look forward to
    seeing it expand over time.

  4. Alanna says:

    You’re so interesting! I do not believe I have read through
    something like this before. So wonderful to discover another person with a few original thoughts on this
    subject. Really.. thank you for starting this up.
    This site is one thing that’s needed on the internet, someone
    with a bit of originality!

  5. When some one searches for his vital thing, so he/she wants to be available that in detail, so that thing is maintained over here.

  6. fast pitch says:

    No longer made of cardboard, trading pins today feature colorful
    designs in soft or hard enamel and bear the year and city where the games were held as well as an Olympic
    logo such as the five interlocking rings or a torch. Students who instead venture into the field of physical therapy must be up to date on the latest exercise sciences.
    You can impart this knowledge by holding skill sessions after practice or
    when adverse weather has prevented your normal weather routine.

  7. Hello friends, good article and nice arguments commented at this place, I am actually
    enjoying by these.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: