It could be quite old thing for you, it has been already discussed on may Forums and weblogs. But now-a-days, I’m working with VHDs on Windows 7 and I thought to blog about this. In my opinion, its one of the best addition to Windows 7 is the Native Support for VHDs(Virtual Hard Disks).
VHD file contains the complete structure representing a Hard Disk Drive, and is used to store or install Virtual Operating Systems and their associated programs. It is used by Virtual PC, Virtual Server and Hyper-V to represent virtual disks.
Virtual Hard Disks also allow multiple operating systems to reside on a single real machine. This enables developers and testers to test software on different operating systems without hassle of host machine.
Windows 7 includes support for creating, mounting, and booting from VHD files. There are two ways to create and mount or attach VHDs, you can either use Diskpart.exe or Disk Management to do this.
As you know Diskpart.exe is the disk partition utility since Windows XP, when create, delete partitions, volumes are come into picture. In past it is managed objects disk, partition and volume. Now in Windows 7, the object “vdisk” has been added, that deals with commands like select, create, delete, attach, detach to do vdisk specific actions.
Here is few high lighted commands, that are invented or re-invented in diskpart.exe
create vdisk file=C:\VHD\W7x86.VHD Maximum=20000 Type=Fixed
Create a VHD at above location size of 20GB with type of Fixed, that means the file size fixed and file will occupy 20GB of space. No matter it is empty or not.
attach vdisk file=C:\VHD\W7x86.VHD
Attach the particular VHD in disk list. You can use “list disk” to see the disks are attached including VHDs.
sel vdisk file=C:\VHD\W7x86.VHD
Select VHD and prepare for disk operations, like create, delete partitions, etc.
Detach the VHD from disk list, first make sure you have already selected specific VHD.
We can say its GUI version of diskpart.exe. Actually Disk Management usages diskpart.exe in background to perform all disk operations. So its much convenient that diskpart command-line utility for newbie.
In Windows 7, Disk Management has two options under Action menu to create and attach VHDs. That follow simple wizard, where VHD size, path, type, etc. are take as input. Rest of things are same as like physical disk and you can simply create, delete, format partitions and all other tasks.
Note: If you have query, whether this information applies to Windows Server 2008 R2 as well. Yes, it does.