I spend a lot of time demonstrating different technologies for different audiences. Because of that I often need to use different operating systems and rather than take along several machines (which I often have to do anyways, but for other reasons) I have taken to configuring my laptop (currently an HP EliteBook 2740p) in a multi-book configuration. When I boot up I get a menu asking me which OS instance I want to boot, and I am off to the races!
Of course, this is easier said then done when some of the operating systems that I use and present change as often as they do – either because of things that I do (domain join, virtualization demos) or new versions (as is the case with the current Windows 8 and Windows Server 2012). This problem is easily solved using the Boot from VHD (virtual hard disk) functionality in Windows 7 (and later).
Step 1: Preparing your host system
Although this is not strictly necessary, I like to partition my physical hard drive and place the VHDs on a separate partition from the operating system that is installed on the physical disk. This is partially a legacy practice from when I would install all of my operating systems for the multi-boot scenario on the disk itself. My current configuration has three partitions, one whose sole purpose is storing the OS VHDs. However thinking about it logically, there is no good reason I can think of why you can’t simply store the VHDs on the C drive.
You need to have the source media for the operating system you plan to install, as well as the imagex.exe file, which is a component of the Windows Automated Installation Kit. You can download this from download.microsoft.com, but make sure you download the version appropriate for the operating system and architecture on which you are installing it.
Because I often work with multiple images, I create a directory on my system called d:\VHDs, and in that folder I create a sub-folder for each image file. So I may have the following directories:
- I prepare the media by copying the
- program into the
- folder, and then from the media of each OS I copy the
- file from the
- directory into the appropriate subdirectory. The
- files are the actual image files of the operating system, and have been standardized since Server 2008 (and Vista).
Step 2: Creating a VHD
There are a couple of ways you can create VHD files within Windows. I prefer to use the Disk Partition Tool (diskpart.exe) but if you want you can also use the Disk Management Tool within the GUI.
- In the Start Menu type cmd.exe and press <Enter>.
- In the command prompt window type diskpart.exe. You should be prompted with a User Account Control window asking for confirmation. (If you are not an administrator you will be asked for credentials) Click Yes.
- (Determine where you will store your virtual disk, and what you will name it. for this example I will call it d:\VHDs\Svr2K8r2.vhd) Type create vdisk file=”d:\VHDs\Svr2K8r2.vhd” maximum=20480. This will create a 20GB VHD file.
- Type select vdisk file=”d:\VHDs\Svr2K8r2.vhd”
- Type attach vdisk
- Type list disk. You should now see a new 20GB disk (the line should have an asterix at the beginning).
- Type exit to quit the Disk Partition Tool.
- I created a 20GB VHD file, but you can size this to your needs. Remember, you may also be installing applications, data, and other tools into your VHD file. However size it to your needs and storage limitations. The minimum should be no less than 9 for Windows 7, 10 for Windows Server 2008 R2.
Step 3: Apply the image to the VHD file
Now that our VHD file is attached to the computer, it is visible in Disk Manager. Load that up (right-click on Computer, click Manage, and in the navigation pane click Disk Management) and initialize the disk, and then create a simple volume. Take note of the drive letter that is assigned to it. For the sake of the later step, let’s say the letter F: was assigned.
We can now apply the image using the ImageX tool.
- In the command prompt navigate to the d:\VHDs folder.
- Because .wim files can contain multiple builds of an OS (such as Windows 7 Ultimate, Professional, and Home Premium) we have to determine which one we will deploy by specifying the index that corresponds to the proper edition. Use the following command to check the Index value of the operating system you want to build: imagex /info d:\vhds\Windows2k8R2\install.wim. This will display all of the editions within the .wim file. If you have a .wim file containing several builds you may want to add the switch |more onto the end so that it will allow you to scroll.
- In this case I want to build a VHD with Windows Server 2008 R2 Datacenter Edition (Full install), which might be Index 4. I will type the following command: imagex /apply d:\VHDs\Windows2k8r2\install.wim 4 F:\ (Here the source media file is d:\vhds\Windows2k8r2\install.wim, and the drive letter assigned to the VHD is F:).
Step 3 will take a few minutes, but when it is done you can list the files and see that it resembles a bootable Windows 2008 R2 hard drive. The problem is that most hardware will not recognize a VHD file as a boot device, so we need to edit the boot configuration data file, or BCD.
Step 4: Editing your Boot Configuration Devices (BCD) file
Although this can be done from the command line (using bcdedit.exe) it is a bit of a pain. there is a free (for personal use only) GUI tool called EasyBCD 2.1.2 which can do it for you.
- Download BCDEdit 2.1.2 from www.neosmart.com. Install the program and run it.
- Accept the EULA. Please note that if you are using this for your work then you must buy the paid version.
- From the menu on the left select Add New Entry.
- In the lower half of the window there is the option to add a Portable/External Media entry to the BCD list. Ensure that Microsoft VHD is selected in the Type box.
- In the name box type the name that you want to appear in the boot menu (such as Microsoft Windows Server 2008 R2 Datacenter Edition (VHD).
- In the path box browse to the location of your VHD file (d:\VHDs\Svr2k8r2.vhd).
- Click Add Entry.
You are done! All ready to go.
For Bonus Points!
- Within EasyBCD you can click on the Edit Boot Menu option on the left, and choose which OS you want to be your default, and your timeout delay… but you have done it! You are ready to restart into either operating system!
- If you want to be able to revert your VHD configuration to this moment all you have to do is copy the VHD file to an alternate location. If you ever hork things up all you have to do is copy over the original and poof, you are clean!
- If you want to get fancy you can add several bootable VHDs to this menu… just follow the same steps!
That’s it. The multi-boot option gets fancier in Windows 8, and I will cover that in a later article. For now, as you know I always look forward to your comments and thoughts, and who knows… I might even give away the occasional prize for a good comment!