The Windows 7 operating system comes with (a new) option to create virtual hard drive [vhd] images that can be mounted in the operating system after creation. It is naturally also possible to mount images not created on the target system as well.
This works pretty much the same way that iso images and other disk images can be mounted in an operating system (usually using third-party software).
VHD images are automatically attached after their creation but never again automatically after the computer system has been rebooted. This is a nuisance for users who need to work regularly with the same vhd image on the computer system.
An easy option to automatically attach vhd images is to use the diskpart command line utility which is part of the Windows 7 operating system. Diskpart is a powerful tool to enable storage configurations from the command line (as well as remote sessions and scripts).
Diskpart can be launched manually by typing in diskpart in the run box in the Windows 7 start menu which will open a new command line window with Diskpart launched.
Update: If you run Windows 8 or newer, tap on the Windows key, type diskpart and hit the enter key. Diskpart will launch as it is included in newer versions of Windows as well.
The first command specifies the vhd image that you want to attach to Windows 7 or newer versions of the Windows operating system.
You can copy the command below but need to adjust the path to the VHD file and the file name of it manually.
select vdisk file=c:\pathtovhdfile
The second command attaches the specified vhd image. What happens here is that Diskpart remembers the VHD image that you have selected using the first command, and uses the information to attach it to the system.
This is the manual process. To automate the process of attaching a vhd to the system do the following:
Diskpart.cmd will be executed on startup of the operating system. It will process the commands in vhdattach in diskpart so that the vhd images will be attached to the system automatically on each start of the PC.
It may be necessary on the first run to go into the disk management tool to format the vhd drives in Windows so that drive letters are assigned to them. The Disk Management tool can also be used to detach vhd images. To run Disk Management, tap on the Windows-key, type diskmgmt.msc and hit enter.Advertisement
Ghacks is a technology news blog that was founded in 2005 by Martin Brinkmann. It has since then become one of the most popular tech news sites on the Internet with five authors and regular contributions from freelance writers.