Skip to content

How to Install Windows 7 on a Virtual Hard Disk (VHD) File?

By Codrut Nistor

Posted in How-to, Virtualization-2, Windows-7

If you are an administrator in an office or you are a simple home user of Windows 7 it is always a real pain in the neck if it gets corrupted and you come to know that you need to reinstall the operating system to bring it back up and running as before. To ease out this problem of administrators various tools are available in the market which are capable of taking backup of the entire hard disk or a particular partition in the form of image. This image can be used to restore your computer quickly and easily whenever it starts behaving abnormally and obnoxiously.

However another even more simpler method to do this is that administrators can install entire Windows 7 operating system on a Virtual Hard Disk and can save the VHD file to a secure location. This VHD file would then work as a backup of Windows 7 operating system. Process of creating and attaching VHD file and installing Windows 7 on it is given below:

  1. On a new computer (in which no operating system is installed) insert Windows 7 installation DVD and start the computer from DVD ROM.
  2. During the process of installation at the first screen that appears select appropriate language time zone and currency and click on Next button.
  3. On the next window click on Repair Your Computer link.
  4. On System Recovery Options box select Use recovery tools that can help fix problems starting Windows. Select an operating system to repair radio button and click on Next button.
  5. On System Recovery Tools page click on Command Prompt link.
  6. In the Administrator: x:windowssystem32cmd.exe command window type DISKPART and press enter.
  7. On the DISKPART prompt type SELECT DISK 0 (assuming that you have single unpartitioned hard disk attached to your computer) and press enter.
  8. On the DISKPART prompt type CREATE PARTITION PRIMARY SIZE=20000 where 20000 is the size in megabytes of the first primary partition of your physical hard disk drive and press enter key. Minimum size should be  10 GB and recommended is 80 GB-100 GB.  Alternatively you can type the command without "SIZE=20000" to assign entire disk space to a single partition.
  9. You will be displayed with the message saying creation was successful.
  10. On the DISKPART prompt type FORMAT and press enter key. (In case any error message appears type SELECT VOLUME 1)
  11. Once formatting is successfully completed you need to type ASSIGN LETTER C: and press enter key. (In case any error message appears type SELECT VOLUME 1)
  12. To create a virtual hard disk file and to store it on C: drive type CREATE VDISK FILE="C:VIRTDISK.VHD" MAXIMUM=15000 where VIRTDISK is the name of virtual hard disk file and 15000 is the maximum size of the virtual hard disk and press enter key. (Note that the size of virtual hard disk should not be more that total size of the partition in physical hard disk where virtual hard disk is stored. For example if while creating partition on physical hard disk you chose 20 GB than your total size of virtual hard disk can only be less than or equal to 20GB)
  13. To attach virtual hard disk type SELECT VDISK FILE="C:VIRTDISK.VHD" and press enter key.
  14. Then type ATTACH VDISK and press enter key.
  15. Type EXIT to come out of DISKPART and again type EXIT to close command window and finally click on close button on the top right corner of the window.
  16. You can now continue with the installation of Windows 7 in regular way. When you will reach where Windows asks for the drive where you want to install Windows 7 you will find two hard disk drives attached namely Disk 0 which is the physical hard disk drive and Disk 1 which will be the virtual hard disk drive that you have created just now.
  17. Select Disk 1 and follow the instructions on the screen to install Windows 7 on virtual hard disk drive.

Using above method you will be able to backup and restore your Windows 7 quite easily and with minimal overhead. Also this method can be used to transfer a preconfigured copy of Windows 7 to any remote location probably a branch office.