How to Create, Attach a VHD in Windows 7

5

One of the good things Microsoft puts in Windows 7 for virtualization is the native support of VHD, which stands for Virtual Hard Disk. If you have used Virtual PC before, VHD shouldn’t be a stranger to you. Since Windows 7, you can easily create, attach, detach VHD files right in the system without using a Virtual platform. You can simply treat a VHD file as a removable disk, like your USB external storage.

There are two ways of doing it, one on the command line and the other uses GUI. Depending on which one you prefer, they are pretty much do the same thing with the same result.

Diskpart – command line

Open an administrator command window. The following are the diskpart commands to create a dynamic VHD that is 25G maximum size, saved in c:\vhd folder. It also formats the partition to NTFS in quick mode, and assigns a driver letter V.

DISKPART
CREATE VDISK FILE=C:\VHD\<filename>.vhd MAXIMUM=25000 TYPE=EXPANDABLE
SELECT VDISK FILE=C:\VHD\<filename>.vhd
ATTACH VDISK
CREATE PARTITION PRIMARY
FORMAT FS=NTFS QUICK
ASSIGN LETTER=V
EXIT

Note that the command diskpart in Windows 7 adds an additional option in Create named vdisk that wasn’t existed in the previous Windows.

Disk Management – GUI option

In Disk Management, click Action box from the top menu, and you can choose either Create or Attach VHD from the menu.

image

When creating a VHD, you need to specify the file name with location, size, and the format. It’s recommended using Fixed size from the performance stand point of view, but usually if you want to quick, you can always choose Dynamic which you can still change later on.

image

We will be covering more on this topic, so stay tuned.

SHARE

5 COMMENTS

    • Good question. One way I can think of is to use of the dispart command and add it into one batch file and put this batch file into the startup folder so it gets run every time when you log in.

      I haven’t tried it so not sure if it works. If you somehow make it work, feel free to leave the comment here.

      Cheers.

  1. OK, so we’ve made a native VHD and installed windows to it.

    How do you

    1) copy the vhd?

    (I rebooted into window 7 startup, went to cmd, did a robocopy of the VHD file… rebooting and trying to attach it I get “Initialise Disk” msg, ie the data on the partition inside the partition is fudged…

    PLEASE, if anyone has backed up a NATIVE vhd, please give specific details!

    Thanks

LEAVE A REPLY

Please enter your comment!
Please enter your name here