I love the performance gains I get by using bootable VHDs. I’ve always enjoyed using VHDs but I generally had a host OS first, then installed a bunch of VHDs that I made bootable. Recently I’ve changed all of this on my laptop after a coworker took the time to show me a way with more flexibility (thanks Paul Stubbs!). The idea is simple: take a clean drive with no host OS and add or remove bootable VHDs as needed.

These steps describe steps that enable a few scenarios for me that allow me to:

  1. Install a fresh OS to a new bootable VHD with no host OS on the computer already
  2. Copy existing VHDs to my physical drive and make them bootable
  3. Boot to any of my VHDs and copy others on, or take some off
  4. To be very clear, these steps are for taking a brand new hard drive or wiping a hard drive clean, and then installing a series of OS’s on VHDs that will boot from disk. The advantage of this is there is no host OS, you can have as many bootable VHDs that fit on disk, and they can be copied on and off the disk at will. I also use create differencing disks (I’ll get into that in another post).

    I like this technique so I don’t have to rely on a base OS. This allows me to copy VHDs on my hard disk, add them to the boot record and run. Or I can install a new OS to a brand new VHD from a DVD, USB or network install. It’s very flexible and since the VHDs boot from the metal they are run very fast!

    This creates a VHD on the metal, on you hard drive without needing a host OS.

    NOTE: This post contains a lot of command line operations that are if typed incorrectly can wipe a hard drive, lose its data, and make it unrecoverable. Use these steps at your own risk, I am not responsible for the outcome. I am simply sharing what works for me.

    I recommend using an SSD if you can. I have found that the performance differences of running off a traditional drive vs. a SSD are tremendous. They are pricey, but I’ve been able to upgrade to an SSD and give my laptop new life.

    Install Windows 7 On a Completely Clean Drive, with No Existing OS

    This cleans my hard drive and sets it up for my 1st VHD that will boot off the metal. These steps only need to be done once to clean the drive fresh. In fact, I don’t ever want to do this again to the drive because it wipes it completely clean (have I repeated that enough times yet? Can you tell I am very careful?)

    1. First, I need to have an OS to install.
      1. If installing from DVD/CD, I make sure the media is in the drive and the bios is set to boot from the optical drive. Then reboot
      2. If installing Windows 7 from USB, I make sure the USB is plugged in and the bios is set to enable USB boot. Then reboot
      3. If installing from the network, after reboot press F12 (if that’s my shortcut key to LAN install) and select the boot OS option.
      4. Once Windows Setup begins and prompts me to begin the installation, I press SHIFT-F10 to get to a command prompt. This is where I will create a VHD and then install the OS onto it.
      5. In the command windows, I enter the disk partitioning utility
      6. Now I list the disks and take note of the disk number for the physical hard drive.
        list disk
      7. Assuming the disk was number 0, I select that disk.
        select disk 0
      8. Now I wipe the drive clean (all of my data on this drive will disappear). I do this so I can start fresh.
      9. Now my drive is clean and ready to be set up. Next I created a partition and formatted it with NTFS file system using quick format. I labeled it “256 GB SSD” so I would always know where the physical drive was. Then I marked it as an active system drive and assigned it a drive letter of C.
        create part primary
        format fs=ntfs label="256 GB SSD" quick
        assign letter=c
      10. At this point I have a fresh drive ready for some VHDs! The next step could be to continue the install of the OS (see next section).
      11. Install a Fresh Copy of Windows 7 on the Metal, in a Bootable VHD

        If I followed the previous steps, I am still in DISKPART. If not, I would follow steps 1-3 in the section above first.

        I repeat these steps whenever I need to install a new fresh OS. I can have as many as my drives fits.

        1. I start by creating a new VHD on the metal where the OS will be installed. It allows me to choose a fixed size or expandable virtual disk file.The advantage of using fixed is that it will always consume X amount of space and be able to boot. Expandable VHDs take up much less space when not used, but they need to have room to expand when they are booted into. I generally use expandable.
          create vdisk file=c:\win7.vhd maximum=50000 type=expandable
        2. Now I select the VHD, attach to it, create a partition on it, and format it. Then I marked it as an active system drive and assigned it a drive letter.

          select vdisk file=c:\win7.vhd
          attach vdisk
          create part primary
          format fs=ntfs label="Win7" quick



        3. Then I exit from DISKPART and exit from the command prompt by typing exit,and exit. This brings me back to the Windows 7 install screen which is waiting for me.
        4. I can now proceed with installation, making sure I choose a custom installation when promoted. Of course, I have to choose the partition I just created. The installation of Windows 7 will happen on the VHD I just created and boot right off the metal. This process creates boot records for me, so I don’t need to create entries using BCDEDIT in the boot record manually which is nice.
        5. Add an Existing VHD to Boot off the Metal

          Sometimes I have an existing VHD that is ready to go and I want to copy it to my computer and run it off the metal. Here are the steps I use to do that. For these steps, I’ll assume I have a Windows 7 VHD with some cool demos on it called Win7MIX11.vhd.

          1. Boot into Windows 7 (for example, one of my bootable VHDs of Win 7)
          2. I copy the Win7MIX11.vhd file to the physical hard drive (might take a few minutes)
          3. Open a Command prompt using Run as Administrator
          4. I run the DISKPART utility
          5. I attach to the VHD and exit the DISKPART utility
            select vdisk file=c:\Win7Mix11.vhd
            attach vdisk
          6. Now I make it bootable, making sure I use the drive letter that the VHD is attached to (I assume X here).
            BCDBOOT x:\Windows
          7. Next I create the boot records so this VHD will be in the list of boot options when I reboot the computer. First I copy a record and give it a name.
            bcdedit /copy {current} /d "MIX11 Demos"
          8. Then I take the GUID that the previous command created and I copy it to the clipboard. I will use this a few times in the next statements.
          9. I enter the follow commands in order, replacing the {myguid} with the GUID I copied to my clipboard a moment ago.
            bcdedit /set {myguid} device vhd=[locate]\Win7Mix11.vhd
            bcdedit /set {myguid} osdevice vhd=[locate]\Win7Mix11.vhd
            bcdedit /set {myguid} detecthal on
          10. Now I can reboot and my Windows 7 VHD for Mix11 demos should show up in my boot options as “MIX1 Demos”
          11. Verification

            Here is a screen capture of my Windows Explorer when I am booted into one of my Win7 VHDs. The D: drive is my physical hard drive, my SSD. Now that I see this I realize I should have made that the C drive letter. Oops. Not a big deal obviously.Smile


            The C: drive is the VHD I am booted into. The total size of my 256 GB SSD is actually 238 GB of usable space. The “Win7 Papa” VHD is booted and is expanded to 50GB. That file exists on the physical SSD. Any other VHDs are also on the SSD. here is the SSD in Windows Explorer. Notice that my file Win7Personal.vhd is expanded to 50GB … this is the VHD I am currently running (which is why its expanded). The other file, win7-01.vhd, is another VHD that I can boot into. It currently takes up 11GB, tho it will also expand to 50GB when I boot to it (and if I do boot to it, the other VHD will no longer be expanded).


            Here is what the Disk Management window shows for my laptop. Notice the SSD and the currently booted VHD show up here too.


            Wrap Up

            This has worked very well for me recently. In addition to Paul Stubb’s help, there are plenty of other resources on the web that I used to help me along, so I wanted to include some of them here too:

            • Less Virtual, More Machine by Scott Hanselman
            • David Anson’s post on creating VHDs that boot off the metal
            • Great shots in this post and in this other post of the screens I see when I install a fresh OS and use the SHIFT F10 technique
            • None of this is earth shattering, its all been done before. I was hesitant at first due to the nature of DISKPART and how a mistake can mean I wiped the drive clean. But recently I decided to upgrade to a new SSD and I had little risk because it was already a new drive. I f you intend on going this route, I recommend researching it first using some f the links I suggested above as well as my experience in this post. But also, make sure you only try this on a drive that is clean or you are OK with wiping clean.