My main laptop doubles as a portable lab, with Windows 8.1 as my main work OS, dual booting with Windows Server 2012 R2 for lab testing purposes, training etc. The Server 2012 R2 install is a HyperV host as well as a domain controller. I boot Server 2012 from a VHD (VHDX to be precise), rather than installing it on a partition, because I want to be able to move this installation to another computer, for instance in order to upgrade my laptop or duplicate the setup on my desktop at home. All I need to do is copy the VHD file to another machine and I am up and running again.
My lapop setup is as follows:
– Lenovo X220 with 8GB of RAM, 250GB Samsung SSD
– 1 x 125GB partition, bitlockered default installation of Windows 8.1
– Second partition, no bitlocker, 111GB
If I was not using bitlocker, I would just have a single partition on the whole disk in in order to minimise space utilisation, but since you cannot boot a VHD from a bitlockered volume, I have to have a separate partition with no bitlocker. This is how the disks look in Windows 8.1 after partitioning:
Create the VHD file as follows:
- Open Disk Management
- Click the Action menu and then and select Create VHD
- I choose 20GB which is plenty when selecting dynamically expanding. I also choose VDHX since I am using Server 2012 R2 (VHDX are only supported in Windows 8.1 and Server 2012 R2 or later).
You could also do this in diskpart during the OS installation, but this is easier:
Now to install an OS to the VHD:
- Insert the Windows Server 2012 or 8.1 DVD or bootable USB key
- Press SHIFT-F10 to get to a command prompt
- Type in diskpart
- Select the vdisk you created: select vdisk file=D:\HyperV.vhdx
- Enter: attach vdisk
- Now exit and then just select the 20GB disk that you created
At this stage I get an error saying that Windows cannot be installed to the volume. However it lets me select the volume just the same and then starts installing and completes without any issues. Once done, you then have Server 2012 R2 installed to the VHDX file, which is on the separate volume. Since I use the machine as a HyperV host, this VHD file then has other VHD files inside it. So when I copy the VHD to another machine, it also copies over all the VMs hosted on that machine.