Earlier, I had posted a tutorial on how to create a virtual hard disk. If you know me well, you probably have not read it because (blah blah blah, add at least two paragraphs of whining… I could take the time to actually write them but that is unnecessay delay. The point is you suck!)

Anyway, let us recap the purpose of a VHD. A Virtual Hard Disk is a file that could, with the help of supporting software, emulate the behaviour of a physical hard disk. They’re of three types – fixed, which means the VHD file should be smaller than the physical harddisk partition it is stored on; incremental, where changes made per session are stored in separate files and the files might well be greater in size put together than the stated capacity of the VHD; and finally, expandable, which expands as more data is added with an upper limit equal to the stated size of the VHD.

What we’re going to do here is not only create a general purpose virtual hard disk but we’ll be booting from it too. This process has been possible since Windows 7. I have already made a video of installing Windows 8 on VHDs. For Windows 7 let’s make it a traditional pic-n-text tutorial.

Unlike the way we did with Windows 8, we’ll do this from the usual environment of Windows 7 we’re most certainly familiar with.

Creating the virtual hard disk

1. Open command prompt as an administrator. Reconsider the rest if you cannot figure out how it’s done.

Diskpart
Just kidding! Type “cmd” in Start and right click on the result. Click on Run as an Administrator and let it…

Type diskpart to start the diskpart prompt.

2. Create a folder in the place you want the VHD to be.

Folder creation
This one you ought to know. If not, respectfully terminate the process of giving a shot to virtual hard disk creation …

3. Create the VHD. This is done using the create command.

create vdisk file=C:VHDWin7.vhd maximum=30720 type=expandable

The location and name of the file could be customised to whatever you like. The maximum size is in MiBs so this examples translates to 30GiB. I’ve set it up as expandable but that’s just to speed up the creation process. I recommend fixed if you want it for keeps.

Create virtual hard disk
Of course, you need not be that specific in deciding the size of the virtual hard disk. Keep it over 20000 for Windows 7. Don’t panic if you see the notification down there – it’s just an acknowledgement that the VHD driver is installed.

Customising the virtual drive

4. Now, you select the VHD you just created.

select vdisk file=C:VHDWin7.vhd

Select the VHD
Here “vdisk” becomes the variable name for the virtual hard disk.

5. Attach the VHD.

attach vdisk

Attach Virtual Hard Disk
This is just like plugging in a flash drive, except since it’s a virtual hard disk, you do it via a command.

6. Create a primary partition. You cannot do this in Computer Management; it has to be done via command. Not specifying parameters makes use of the whole VHD in one partition.

create partition primary

Tip:

DiskPart can understand shortened commands too. The above command could be written as cre part prim and it’ll still work. The trick is to shorten commands to only the extent to which it’s clearly understood which command you’re typing. active could be written as act and select as sel.

Create partition
When you attach the disk it automatically selects the virtual hard disk as its drive to focus on…

7. Activate the partition.

active

Mark active
Well, activate won’t be the right word for it. This command marks the partition as active which means if there were more partitions, the system would only choose this partition to boot from in this specific virtual hard disk.

8. Format the partition.

format fs=NTFS unit=512 label=VHD quick override

Format the partition
The unit, label, quick and override parameters are not obligatory. Label just helps in differentiating the drive. Quick and override are quite self explanatory.

9. Assign the partition a drive-letter

assign letter=z

Assign drive letter
You can let it have whichever drive letter you’d like.

10. Leave the DiskPart prompt.

exit

Leave the DiskPart prompt
You can type “exit” or just close the prompt window.

Side-loading the installation

11. Open the file install.wim in the sources folder of the installation disk using 7-zip.

Open the WIM file.
This is one of the easiest ways to open and extract WIM files. The numbered folders here actually contain entire copies of Windows 7 in the order Home Basic, Home Premium, Professional and Ultimate.

12. Decide which edition of Windows 7 you’d like to install on the virtual hard disk. You’ll need to feed in a product key to activate the copy later. Enter the right folder, select all the contents and ‘extract’ it to the VHD, in this case at the location Z:

Extract one of the copies
You could select any of the four folders in 64bit. There’s bound to be more in the 32bit installation disk. I’ve chosen Ultimate which is the 4th.

Creation of boot-loader entry

13. Open up another command prompt as an administrator. Check your boot-loader using BCD editor.

bcdedit

BCD editor
You never usually see the boot-loader menu since you’re running just one OS.

14. Create a new entry.

Do this by typing the following:

bcdedit /copy {current} /d “Windows 7 VHD”

Create boot-loader entry
Here you’re creating a new entry by copying the existing one to save the effort of feeding all parameters. The parameters can be instead changed easily.

Once you’ve done this it’ll be nice to just copy the identifier string into the command prompt clipboard. Do that by right-clicking within the prompt window and selecting the string including the braces, then clicking the Return/Enter key. The above snippet is how it looks before you tap on Enter. The copied string speeds up the process. But for further instructions I’ll use {string} as the identifier.

15. Check if the new entry has appeared in the boot-loader by typing bcdedit.

Check boot-loader
Checking if the entry is made correctly is always a good thing. As you can see, there are two entries now – one with description “Windows 7” and the other with “Windows 7 VHD”

16. We’re going to feed in 3 commands now to change the parameters to properly boot from the VHD.

bcdedit /set {string} device vhd=[C:]VHDWin7.vhd

bcdedit /set {string} osdevice vhd=[C:]VHDWin7.vhd

bcdedit /set {string} detecthal on

Here, we’re changing the device to boot from and the device the OS is in as the virtual hard disk. Setting the HAL detection makes this copy of Windows 7 installation aware of the fact that it is booting from a VHD.

Tip:

Use the correct string in place of {string}. The string you marked earlier can be pasted by right-clicking and selecting Paste.

Also, the first and second command are quite identical. Use the Up arrow key to reveal the previous command and add the “os” before “device”.

Setup boot-loader
You’re setting up the parameters of the second entry so it successfully boots from the VHD when you select the second option.

Verification

17. Check if all the changes have taken effect. It is always good to check that. You’ll find the relevant stuff updated to point to the VHD quite well.

bcdedit

Verify boot-loader
Verifying the entries cannot be done enough. It’s a sickness among those who want to get it right the first time.

That’s it!

All you need to do now is close the prompt and restart your computer.

When the computer reboots, it’ll show you a list of options to boot from including the new entry. Select the new entry for it to complete initial setup. This process essentially skips over all of the general setup routine and immediately takes you to the first boot process.

Advantages of virtual hard disk booting:

1. You can easily create as many of them as you need limited only by the physical space on your hard disk.

2. The VHD file is transferable to a different PC before the first setup. You can copy the disk and store it some place safe. If something happens to your VHD system, all you got to do is replace it with the copy of the original file and it’ll be good as new.

3. If you like how the setup at any given time is, the file can be saved as an insurance to possible future catastrophes.

4. Removing the drive letters from storage of your physical computer, you can literally isolate the environment for experiments and it does not affect your main system in the slightest.

5. With a large enough flash drive, the initial setup could be made mobile. However, once setup that machine will only boot correctly on one PC. Still, good enough to have a backup fully functional system.

Disadvantages:

1. None other than Windows 7 and Windows 8 along with their server counterparts can natively boot from virtual hard disks. There have been instances of Ubuntu doing it, but in reality the OS isn’t aware of it. The boot loader of Ubuntu, creates a safe environment for it to boot in as a normal system with reduced functionality – it’s basically running in an emulator.

2. System performance will drop by 3%; that is just the read-write performance. Everything else will perform just as normally as they do. Not at all problematic, but this will not allow a system performance rating.

I guess that’s it. So my true sequel to Windows 7 – a feature that caught my eye is complete after all this time. It’s quite weird to do a video on Windows 8 virtual hard disk installation and in a few days get back to Windows 7, but better late than never.

Birthdays are just days. It shouldn’t mean anything special. Help me prove it by buying me stuff on basically any day. Click on Buy me stuff up top for more details.

Leave a comment

Your email address will not be published. Required fields are marked *