Skip to main content

How to Create and Permanently Attach a Virtual Hard Disk

 

How to Create and Permanently Attach a Virtual Hard Disk in Windows 7

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 “Browse”, 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 available letters.Click on “Next”.
Before formatting the volume, choose the file system, give a volume level and click on“Next” then “Finish”.
You are done! You cannotice that your new virtual hard disk has been listed with the other disk drives.

Attach an existing Virtual Hard Disk

Right click on My Computer icon then select “Manage” to open Computer Management wizard. Now under the “Storage” entry, right-click on “Disk management”. Select “Attach VHD” and locate the existing vhd file and click on OK. That’s 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 virtual drive and you’ll have to reattach the VHD again. There is a simple tricks by which you can make the virtual drive permanent and you won’t have to reattach that after every time you start your computer.

Permanently attach Virtual Hard Disk in Windows 7

To make the virtual hard disk permanent, create a batch file to attach the VHD and run that at start up by creating a registry entry. Here is the complete procedure.
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 location. 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 at C: > Windows > System 32 folder. When pasting the file there you will get a security 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 > Run
Now create a new string value under “Run”. Right-click on the empty space of the right pane and select New > String Value.
Give a name of the value. Here it is VHD. Now right click on the value VHD and select“Modify”.
At the Value data field put “c:windowssystem32some_name.bat” and click OK.

Comments

Popular Posts