Andrew Connell

Moving Exclusively to Boot-to-VHD's

Forward: I’ve known this was possible for quite a while, and know one or two people who do it ( Paul Stubbs ), but it wasn’t until just recently that I decided to bite the bullet.

Recently I had nagging issues with my primary Windows 7 install. Occasional lock ups, driver issues, services not starting automatically, A/V not starting automatically, etc… I knew a rebuild was in order. I elected to move exclusively to a boot to VHD option. In this you don’t install your OS to the metal… instead you use virtual hard disks (VHDs). Why do this? It really simplifies your HDD in my mind and the backup story is fantastic (just copy a massive file to an external drive for safe keeping).

My Previous Setup

My machine has two 512GB SSD’s ( the awesome Crucial M4’s ). One sits in the primary laptop drive (I have a Lenovo ThinkPad W520 ) that had Windows 7 installed on it. It also had a folder for VHDs. My other drive sat in a caddy that replaced the DVDROM… more on that in a moment.

As a SharePoint instructor/speaker/developer, I need to run SharePoint. I prefer to use Hyper-V for my virtualization solution for various reasons and can’t have my host be unstable/unreliable (that excludes VMWare, VirtualBox or Windows 8 pre-RTM). So on my primary drive I had a c:\VHDs. I had a boot-to-VHD OS of Windows Server 2008 R2 with the Hyper-V role enabled on that primary drive (yeah… I boot to an OS as that is in a VHD and that OS has Hyper-V enabled and it can run VMs from there… pretty crazy… kind of like “what would you see if you pulled your eyes out and pointed them at each other eh?”… but I digress…). All the virtual machines & their VHDs that were hosted by Hyper-V were stored on the 2nd drive in the caddy.

I could have additional VHDs that I booted into (such as to play with Windows 8).

New Setup

So I formatted the drive and decided to go VHD all the way. I still use my 2nd drive to store the VMs & their associated VHD’s that I run when in the Windows Server 2008 R2 Hyper-V VM. My primary drive has a few folders on it… these are things I want to access from the different OS’ I install. For instance, my D:\Dev folder is where I do all my development & have my references, D:\Mesh is where I keep folders I have in Live Mesh (my primary OS has Mesh installed that keeps it in sync with my Windows Home Server 2011 ), but the important one is the D:\VHDs… that’s where my bootable VHDs are:

Windows Explorer

Windows Explorer

When I boot my laptop, I have a few options I can boot to:

  • (VHD) Windows 7 Primary
  • (VHD) Windows Server 2008 R2 Hyper-V
  • (VHD) Windows 8 Release Preview

How to Set it up

In a nutshell, I followed the steps from John Papa’s excellent post Installing a Fresh Windows OS to a New Bootable VHD with no Host OS for Boot to VHD (damn that’s a mouthful). His steps are clear and concise. Basically you do this:

  1. Clean the disk & prime it for creating VHDs to boot form. John’s section Install Windows 7 On a Completely Clean Drive, with No Existing OS shows how to do this, but it’s not entirely accurate in the title as you don’t install anything… you just format the disk and give it a name.
  2. Create a VHD and mount it. John’s section Install a Fresh Copy of Windows 7 on the Metal, in a Bootable VHD shows this… just follow his steps. I skip the part about adding a key when installing the OS… you’ll see why in a moment.

After I did these steps I then installed all the patches, drivers and core apps I want on every install. For a Lenovo laptop, I got the System Update utility which is basically Windows Update for Lenovo laptops. It’s awesome as it looks at your hardware and downloads & installs all drivers you need for your machine. Then I run Windows Update to get the OS patches. Other apps I install are things like Live Essentials , Security Essentials , NotePad++ , WinRAR, and FileZilla . Then, I run SYSPREP on the VM.

After SYSPREP runs, I make a copy of the VHD (usually this means booting from a USB stick and using the command prompt to make a copy of the VHD). This way later I can easily copy the VHD over and have a new clean OS that’s fairly current pretty quick. All you have to do is re-run Lenovo’s System Update, Windows Update, give the machine a name & enter a license key. Poof… new OS in a few minutes! In order to add an existing VHD as a bootable option, follow the steps in John’s section Add an Existing VHD to Boot off the Metal.

A Few Helpful Tricks

A few more tricks helped me out.

Pesky Drive Letters

I had issues where my drive letters weren’t exactly what I wanted. For instance, in the screenshot above, my D:\ kept showing up as E:\. I’m anal… I don’t like that. Data on D:\ damnit! Sometimes it didn’t work just changing letters because the page file was in use. To resolve, first go in and turn off the page file, reboot, change the letter and then check the “let system manage the page file”.

Resizing the VHD

Following John’s steps I created a dynamically expanding VHD that could expand to 50GB. Uh… bit short sighted there :) Thankfully you can fix this. Boot into an OS where you aren’t using the VHD (or a bootable USB drive and use DISKPART.EXE to configure the drive to expand to a bigger size:

  • SELECT VDISK FILE=[full path to VHD]

That just configures the VHD to expend to a bigger size. Next, boot into the OS and use Disk Management to expand to the remaining free space.

Andrew Connell
Developer & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a web developer with a focus on Microsoft Azure & Microsoft 365. He’s received Microsoft’s MVP award every year since 2005 and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s the founder of Voitanos and is dedicated to delivering industry-leading on-demand video training to professional developers. He lives with his wife & two kids in Florida.