Creating a VHD File with diskpart

Creating a VHD File with diskpart
You might occasionally want to have another instance of Windows 7 available on your system. You can do this with a virtual hard disk (VHD) file. This has several benefits:

·        The VHD file is just like any other file on your system, though much larger than most files. You can copy the VHD file to ensure you can always return it to the original configuration, or copy it to make it available on a different system.

·        It configures your system as a dual-boot system. When you reboot, you can choose to boot into the VHD file or boot normally into Windows 7.  

·        You can use the VHD file for testing. You can test updates, check compatibility of software, or even release and observe malware in an isolated environment. When you’re done, you can simply copy your original file back over the modified VHD file.

You can use the following steps to create and attach a VHD file to your system. If you wanted to create a dual-boot or multiboot system with a VHD file, you would perform these steps as part of the installation process. In other words, you would first perform these steps:

Step 1. Boot to the installation DVD as if you are going to install Windows 7.

Step 2. When you get to the screen where you select the language, time and currency format, and keyboard or input method, press Shift+F10. This launches the command prompt.

Step 3. Use the steps in the following table to create the VHD.

Step 4. Install Windows 7 on the VHD.

Use these steps to create a VHD file on your system:

diskpart Commands
Launches diskpart.
DISKPART>create vdisk file=
c:\win7pcg.vhd maximum=20480
Creates a virtual hard disk (.vhd) file named win7pcg.vhd in the root of the C: drive. The file will be expandable and can grow to as big as 20 GB if you use a maximum size of 20,480. The initial size is about 40 Kb.
DISKPART>select vdisk file=
Selects this virtual disk file so that it can be attached and used.
DISKPART>list vdisk
Shows vdisk 0 with its location. It will have an asterisk (*) on the left indicating it is selected, but it is not attached yet.
DISKPART>attach vdisk
Attaches the vdisk so that it can be used.
DISKPART>list vdisk
Shows vdisk 0 as a disk with a state of attached but not open and a type of expandable.
DISKPART>list disk
Shows all of the disks with the 20-GB vdisk added.
Exits diskpart.

You can now continue with the installation of Windows 7. When prompted to select a disk, select the 20-GB disk, which is the vdisk you created. It will not be formatted, so it will show as unallocated space, but the installation will automatically format this disk with the NTFS file system as part of the installation process.
Read: Mapping Drives with net use

No comments:

Post a Comment