Administering Windows Virtual Disks


Virtual Disk

    Photo by teclasong

While reading my daily blog roll I ran across a posting at the always informative Train Signal Training blog about VHDs, or Virtual Hard Disks. This really caught my eye as I hadn’t heard of this functionality before. Virtual disks have been a part OS X since the beginning (I believe they go back to the NeXT days) and I find them to be very useful. It’s great to see this capability now in Windows 7 and Server 2008 R2. The steps to create and use a VHD are a bit more complicated than creating a DMG on the Mac, but that’s a small price to pay for the capability.

As usual, I’m interested in the command line options and here Microsoft doesn’t disappoint. The DiskPart.exe utility provides all the necessary functionality to create, partition, format, and use a virtual disk. Here’s a session that creates a 32 GB disk and assigns it a drive letter.

PS C:\> diskpartMicrosoft DiskPart version 6.1.7600Copyright (C) 1999-2008 Microsoft CorporationOn computer: AADEVDISKPART> create vdisk file="c:\test.vhd" maximum=32000 type=expandable 100 percent completedDiskPart successfully created the virtual disk file.DISKPART> select vdisk file="c:\test.vhd"DiskPart successfully selected the virtual disk file.DISKPART> attach vdisk 100 perent completedDiskPart successfully attached the virtual disk file.DISKPART> create partition primaryDiskPart succeeded in creating the specified partition.DISKPART> list partition Partition ### Type Size Offset ------------- ---------------- ------- -------* Partition 1 Primary 31 GB 1024 KBDISKPART> select partition=1Partition 1 is now the selected partition.DISKPART> format quick fs=ntfs 100 percent completedDiskPart successfully formatted the volumeDISKPART> list volume Volume ### Ltr Label Fs Type Size Status Info ---------- --- ----------- ---- ----------- ------- --------- ------ Volume 0 D CD-ROM 0 B No Media Volume 1 System Rese NTFS Partition 100 MB Healthy System Volume 2 C NTFS Partition 127 GB Healthy Boot Volume 3 NTFS Partition 31 GB HealthyDISKPART> select volume=3Volume 3 is the selected volume.DISKPART> assign letter=VDiskPart successfully assigned the drive letter or mount point.DISKPART> exitLeaving DiskPart...PS C:\> copy license.xml v:\PS C:\> dir v:\ Directory: v:\Mode LastWriteTime Length Name---- ------------- ------ -----a--- 9/08/2010 2:41 PM 418 license.xml

As you can see, it’s pretty straightforward to create and use a VHD. You can even install Windows on a VHD and boot to it, which can be very useful for troubleshooting. I love finding a new features that I didn’t know about and can explore.

Looking for unattended installation software? Download a free copy of PDQ Deploy.