Booting an OS from VHD was introduced in Windows 7/Windows Server 2008 R2 but it became more popular after the launch of the next OS generation. It lets you place a VHD on one of your current partitions and install an operating system on it, behaving like a second boot partition. This makes it much easier to maybe test a new OS on your computer without repartitioning the hard disk. The process is very simple and straight forward; everything is set up from the Windows Installation wizard.
I have a useful post about opening a command prompt during the Windows installation: Open Command Prompt during Windows installation. This tip will be used here to configure boot from VHD.
Set up boot from VHD
I am using a virtual machine for this demonstration but the practical side of this feature is that you can use it on your hardware. Firstly make sure you have a partition with enough free space to accomodate a VHD with a full OS installation on it. I have a single disk with 1 partition on my VM and the free space is about 30 GB; more than enough.
Insert your installation media. As you can see I have a DVD with Windows Server 2016 Technical Preview 5. The primary OS on my virtual machine is Windows Server 2012 R2. Start or restart your machine and boot from the newly inserted media.
Next up is opening a CMD window to create the VHD and attach it to this instance. The command prompt can be obtained with the SHIFT+F10 key combination. Once there just run DISKPART.
First thing to do is determine what letter your partition on which you will put the VHD has assigned. Do not assume you know because this could change from boot to boot. Finding this partition is simple: just list of volumes and find the one you are looking for by name or size.
Luck has it that my OS partition has the letter C exactly like when booted in the primary OS. With this information handy it is time to create a VHD file in my case on C. I will place it directly in C:\ and name it sec.vhd. The size will be of maximum 20 GB and I will make the disk dynamic or expandable so it will only occupy the space it really needs.
CREATE VDISK FILE=C:\sec.vhd MAXIMUM=20000 TYPE=expandable
Altough the disk is created, it is not yet seen by this OS instance. It first needs to be selected so it is the active disk in the DISKPART utility and attached so it will be seen in the current OS. The commands to do this are:
SELECT VDISK FILE=C:\sec.vhd ATTACH VDISK
Cool. Close the CMD and go on until you get to choose the partition on which you install your new operating system. The VHD will be present in the list. Choose it and go on until the installation is done.
Every time you reboot you will see an OS select screen for 30 seconds. The new installation will become the default operating system but this can be changed easily.
That was it. 2 operating systems can boot and no repartitioning had to take place. The boot menu settings can be changed from the MSCONFIG tool.