There are times when we need more than one operating system on our computer. We can build a dual or multi-boot OS’s, but it requires us to make a lot of partitions for the OS file systems, and that is not always comfortable.
Another way to set a multi-boot OS’s on our computer, is creating a VHD file and then to install operating system on it. It’s easier and does not require to change partitions on our disk, also we can store the VHD file in any place.
Create
and configure VHD
To create and configure Virtual Hard Disk file, first of all, we need to install WAIK (Windows Automated Installation KIT). It can be downloaded free from Microsoft website.
Open the “Deployment Tool Command Prompt” as administrator
Type the following commands to create and configure the VHD file.
Diskpart
Create a file in d:\vhd directory and configure it’s size to 50 GB. Type=fixed command, will let the file to be able to expand, if it fills up.
Create vdisk file=D:\VHD\SRV2008R2.vhd maximum=50000 type=fixed
We can create the file in any place on our hard disk.
Select the vhd file that we have created.
Sel vdisk file=D:\VHD\SRV2008R2.vhd
Attach the disk in the system.
Attach vdisk
List the disks to see our new attached disk marked with the star.
List disk
Select the disk we have just created.
Sel disk
Create primary partition on the new disk. Here we can create the number of partitions we need.
Create part primary
Select the primary partition.
Sel part 1
Set the partition as active.
Active
Format the partition.
Format fs=ntfs quick
Add the vhd file as the different disk in our system.
Assign
Exit the diskpart.
Exit
Deploying the OS on the VHD
In order to deploy the OS on the VHD, first of all, we need to put the install.wim file in the directory of our VHD file – d:\vhd.
Install.wim file is the file that contains the OS installation components and is located on the installation media in source folder. That’s the only file that we need to make the OS installation. We need that file only to deploy the OS, later it can be deleted.
Type the following commands to deploy the OS on VHD file.
It gives us the info of the wim image file.
Imagex /info /D:\VHD\install.wim
Here we see the index of the image. This is telling us that the image contains just one OS installation.
Imagex is applying the OS installation on the vhd disk and checks it for errors. The i:\ letter is the letter of the attached vhd file, which becomes a different disk in our system.
Imagex /apply D:\VHD\install.wim /check 1 i:\
After applying we can see the files of the operating system that we flashed to the VHD disk.
At the end of the applying we need to detach the VHD disk.
Open the disk configuration tool.
Diskpart
Select the VHD file.
Sel vdisk file=D:\VHD\SRV2008R2.vhd
Detach the virtual disk from the system.
Detach vdisk
Exit the diskpart issue.
Exit
Configure the boot order
Type the following commands to add and configure the boot order of our system.
Open the boot configuration tool.
Bcdedit
The command will copy the existing entry of our system. Then we will edit the entry and route it to our VHD file.
Bcdedit /copy {current} /d “Boot from VHD”
The “Boot from VHD” is the description of the entry. This name will be shown later in our boot menu. Here we can enter any name that we want.
Type the command to see the new Windows Boot Loader entry.
Bcdedit
At the bottom of the entry, we will see the identifier of the new entry, with this identifier, we will route the entry device to the VHD file.
Bcdedit /set {695e6661-3b6c-11df-af4f-a9a9eb462739} device vhd=[D:]\VHD\SRV2008.vhd
This will configure the osdevice to the VHD file.
Bcdedit /set {695e6661-3b6c-11df-af4f-a9a9eb462739} osdevice vhd=[D:]\VHD\SRV2008.vhd
Turn on the detecthal.
Bcdedit /set {695e6661-3b6c-11df-af4f-a9a9eb462739} detecthal on
If we need to edit the description of our entry, typing the following command with the identifier of the relevant entry and edit the entry description in the boot menu.
Bcdedit /set {695e6661-3b6c-11df-af4f-a9a9eb462739} description “Server 2008”
If we type the command
bcdedit
we will see the new, configured Boot Loader.
Finally, restart the machine and boot into the VHD machine.
Done.
You can add as many VHD machines as you want.
Enjoy.