Wednesday, March 27, 2013

Windows 8 and Native VHD Booting

In my last blog post I mentioned how I was really happy that my desktop processor supported SLAT and how it meant I could activate Hyper-V in Windows 8 Professional. This is because I wanted to play around with running virtual machines on the desktop.

My primary machine has a 30GB SSD as the boot drive and two 500GB HDDs.  Initially I was keen to try the virtualisation approach so I could play around with images but then I remembered one of the presentations I attended at TechEd 2012 that talked about booting into virtual images.  This would be an excellent way of having three machines.

The first base install would boot to Win 8 Pro using the SSD, the second virtual machine would boot to Windows 8 with Office installed, and the third virtual machine would boot to another Windows 8 with Steam and installed.  It would allow me to negate the restrictive 30GB limit on my boot drive and provide me the speed of booting to 'bare metal' rather than running an image on Hyper-V and using remote desktop to access it.

I did a little bit of investigating and used the following steps:

1. Create Virtual Machine
2. Start Virtual Machine
3. Update Virtual Machine
4. Shutdown Virtual Machine
The first bit of work took place within Hyper-V as I created the two Virtual Machines, started them up and remoted into them, then ran Windows Update and used the Action Center to apply any changes or updates to the images.  Now I have a virtual machine and an associate virtual hard drive ready to play with.

5. Start Disk Management
6. Select Action | Attach VHD
7. Select VHD created with Virtual Machine
8. Remove the Drive Letter from the System Reserved volume
9. Set the Drive Letter for the Primary Volume
The second set of steps involved using Disk Management to attach the virtual hard drive, remove the drive letter from the boot partition for the virtual hard drive, and set the drive letter for the primary volume in the virtual hard drive.  Now my virtual hard drive is visible to the system within disk management.

10. Start a CMD Prompt
11. Navigate to [Drive Letter]
12. Navigate to \windows\system32
13. Use bcdboot to add configuration data to the drive:
bcdboot f:\windows
I then accessed the new drive using the drive letter and ran bcdboot which creates a set of Boot Configuration Data on the virtual hard drive.  Now this virtual hard drive should be seen as a bootable partition.

14. Reboot
15. Select the one you want
Use the "Choose an operating system" prompt to boot into whichever partition you want to, but we're not quite done here.

16. Open elevated command prompt
17. Use bcdedit command to retrieve GUIDs for each boot partition:
18. Use bcdedit command to set descriptions:
bcdedit /set {big guid 1} description "Windows 8"
bcdedit /set {big guid 2} description "Windows 8 Games"
bcdedit /set {big guid 3} description "Windows 8 Office"

19. Use bcdedit command to automatically launch Hyper-V
bcdedit /set hypervisorlaunchtype auto
The bcdedit command allows you to manage the configuration data associated with any bootable drive.  Now we have given our boot drives appropriate and easy to determine names.

21. Select Boot
22. Check the boot options for each drive and set the default
Finally we just need to check the boot option and set a default - Windows 8 will boot into the default after a set number of seconds if the system receives no inputs.

This is so very convenient for me.  If I want to quickly get online, I boot into the SSD partition, which is the default - and will go from the selection screen to the lock screen in under 4 seconds.  If I want to use Office or access photo editing software I boot into the office image, and if I feel like playing games I use that image.

All my image are held on my E: drive, which is 500GB.  Each image is dynamic but set to 130GB to start with.  Each machine is part of my Windows Home Server network and automatically backs up if it is on.  I generally boot each machine up once a week to apply any updates.

That's not all, though - I also use the library management tools of Windows 8 to make sure that the locations for all the libraries - and a few additional ones I've added - are on the D: drive.  This means that every one of these images share the same base data, from downloads to documents and everything in between.  More on that soon.

In conclusion, my desktop is now three desktops.

1 comment:

CJ said...

Nice !

Also, since the two (Game & Office) machines are based on VHD files, it also means you can back up which ever is not currently running just by copying / archiving the VHD file.

aree any of the images bitlock encrypted as well to prevent theft ?