How to Create, Attach a VHD in Windows 7

Posted by Kent on May 18th, 2009, in How to, Virtualization tagged in: , ,
FREE scan: Click Here to Fix Windows 7 Errors & Improve Windows 7 Performance

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.

Subscribe to W7H Tips & Tricks (Why?)

Email:

You may also like:

Comments (2)

  1. Can a VHD be persistent, so it will be mounted on bootup

    • Kent says:

      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.

    Trackbacks/Pingbacks (4)

  1. How to Create, Attach a VHD in bWindows 7/b | bWindows 7/b Hacker « Windows 7 Live Info
    [...] kent wrote an interesting post today onHow to Create, Attach a VHD in bWindows 7/b | bWindows 7/b HackerHere’s a quick excerptOne of the good things Microsoft puts in bWindows 7/b for virtualization is the native support of VHD, which stands for Virtual Hard Disk. If you have used Virtual. [...]
  2. Native VHD Boot to Windows 7 | Windows 7 Hacker
    [...] can simply follow my previous post how to create attach a VHD in windows 7, in which it describes two options to create a VHD natively in Windows [...]
  3. Mouse Right-Click to Attach and Detach VHD Image File in Windows 7 | Windows 7 hacker
    [...] this topic.One of the nice things Microsoft puts in Windows 7 is the native support of VHD. You can create, attach, and detach a VHD image file either from Disk Management or through Diskpart dos command. However, either way you will need to [...]
  4. Windows 7 New Features and Tips & Tricks That We’ve Covered in 2009 | Windows 7 hacker
    [...] How to Create, Attach a VHD in Windows 7 [...]

Leave a Reply