You are on page 1of 2

Virtual Hard Disk (VHD) is a file, created in Windows 7, that behaves as a separ

ate usual hard disk drive of the computer. You can keep your favorite files and
folders, apply disk encryption etc. Even, you can boot from that virtual disk dr
ive by configuring the boot manager. This tutorial shows how to create a virtual
disk drive in Windows 7, attach an existing VHD and lastly, the procedure of ma
king the attachment permanent in step by step.
Create Virtual Hard Disk (VHD)
You can create a virtual hard disk from Computer Management wizard.
Right-click on My Computer and select Manage.
or, type compmgmt.msc at the Windows 7 start menu search box and hit Enter. The
Computer Management wizard will appear. Now follow the steps below.
Right-click on Disk Management under Storage and click on Create VHD.
In the next wizard select the location and the VHD file name by clicking on Brows
e, put the size of the virtual hard disk in MB and click on OK.
This will create the Virtual Hard Disk with the level Disk 1.
Now right-click on Disk 1 and select initialize then click Next.
After initializing the disk, you have to allocate the disk space. So right-click
on the unallocated space and select New Simple Volume.
In New Simple Volume wizard put the volume size and click on Next.
Assign a drive letter for the drive by choosing from the drop down list of avail
able letters. Click on Next.
Before formatting the volume, choose the file system, give a volume level and cl
ick on Next then Finish.
You are done! You can notice that your new virtual hard disk has been listed wit
h the other disk drives.
Attach an existing Virtual Hard Disk
Right click on My Computer icon then select Manage to open Computer Management wiz
ard. Now under the Storage entry, right-click on Disk management. Select Attach VHD an
d locate the existing vhd file and click on OK. Thats all.
So after creating a new Virtual Hard drive or attaching an existing one, you can
access it from the Windows 7 explorer window.
But the problem is that every time you restart your computer, you lost the virtu
al drive and youll have to reattach the VHD again. There is a simple tricks by wh
ich you can make the virtual drive permanent and you wont have to reattach that a
fter every time you start your computer.
Related: Create Virtual Drive for any folder.
Permanently attach Virtual Hard Disk in Windows 7
To make the virtual hard disk permanent, create a batch file to attach the VHD a
nd run that at start up by creating a registry entry. Here is the complete proce
dure.
Creating the batch file
Copy the following code and paste in a notepad document.
@echo off
SET TEMPFILE="%TEMP%\%RANDOM%.TXT"
echo SELECT VDISK FILE=Your vhd file name with location >%TEMPFILE%
echo ATTACH VDISK>>%TEMPFILE%
DISKPART /s %TEMPFILE%
del %TEMPFILE%Replace the high lighted part with the vhd file name along with lo
cation. As for example E:\myvirtualdrive.vhd
Now save the file as some_name.bat. Also change the Save as type to All files before
saving. After creating the batch file copy the file (some_name.bat) and paste a
t C: > Windows > System 32 folder. When pasting the file there you will get a se
curity message. Just click on Continue.
Creating the registry entry
Press Win key + R and type regedit and hit Enter to open the registry editor. Now
navigate to the following path from the left pane of the editor:
HKEY_LOCAL_MACHINE > SOFTWARE > Microsoft > Windows > CurrentVersion > RunNow cr
eate a new string value under Run. Right-click on the empty space of the right pan
e and select New > String Value.
Give a name of the value. Here it is VHD. Now right click on the value VHD and s
elect Modify.
At the Value data field put c:\windows\system32\some_name.bat and click OK.
Restart your computer. You can notice the virtual drive that you created or atta
ched has been permanently occupied in the explorer or any other places.

You might also like