Home » BCD » Creating a Multi-OS Environment with Boot from VHD

Creating a Multi-OS Environment with Boot from VHD

If you value or enjoy this blog please feel free to donate. I receive no compensation for it and do not sell my endorsements.

Follow me on Twitter

Archives

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 2,402 other followers

Computers that contain this sticker met the re...

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:

  • d:\VHDs\Windows8RP
  • d:\VHDs\Windows2K8R2
  • d:\VHDs\Windows2012RC
      I prepare the media by copying the

imagex.exe

      program into the

d:\VHDs

      folder, and then from the media of each OS I copy the

install.wim

      file from the

\sources

      directory into the appropriate subdirectory.  The

install.wim

    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.

  1. In the Start Menu type cmd.exe and press <Enter>.
  2. 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.
  3. (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.
  4. Type select vdisk file=”d:\VHDs\Svr2K8r2.vhd”
  5. Type attach vdisk
  6. Type list disk.  You should now see a new 20GB disk (the line should have an asterix at the beginning).
  7. Type exit to quit the Disk Partition Tool.

NOTE:

    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.

  1. In the command prompt navigate to the d:\VHDs folder.
  2. 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.
  3. 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. 

  1. Download BCDEdit 2.1.2 from SNAGHTML160d484www.neosmart.com.  Install the program and run it.
  2. Accept the EULA.  Please note that if you are using this for your work then you must buy the paid version.
  3. From the menu on the left select Add New Entry
  4. 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.
  5. 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).
  6. In the path box browse to the location of your VHD file (d:\VHDs\Svr2k8r2.vhd).
  7. 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!

About these ads

31 Comments

  1. Mitch,

    Boot from VHD is nice, but in this day and age when partitioning re-sizing is so safe and common that the Ubuntu gui installer will offer to do it for you, is it really necessary?

    • Mitch Garvis says:

      Hi Justin,
      While I agree with you that partition resizing is safe and commonplace, for people who need to be able to revert to where they were at the beginning of every demo it is easier to use Boot from VHD and replace the file than it would be to redeploy the OS. Also we can only create up to four (4) partitions on a hard drive, one of which is taken by the BCD partition. The Boot from VHD scenario allows us to have as many OSes as we want.

      Thanks for reading! -M

  2. […] Creating a Multi-OS Environment with Boot from VHD (garvis.ca) 43.651745 -79.376094 Rate this:Share this:ShareEmailPrintTwitterFacebookLike this:LikeBe the first to like this. […]

  3. My Homepage says:

    … [Trackback]…

    […] Find More Informations here: garvis.ca/2012/06/20/boot-from-vhd/ […]…

  4. […] Creating a Multi-OS Environment with Boot from VHD (garvis.ca) 43.651631 -79.375852 Rate this:Share this:ShareEmailPrintTwitterFacebookLike this:LikeBe the first to like this. […]

  5. homepage says:

    … [Trackback]…

    […] Informations on that Topic: garvis.ca/2012/06/20/boot-from-vhd/ […]…

  6. … [Trackback]…

    […] Read More here: garvis.ca/2012/06/20/boot-from-vhd/ […]…

  7. הובלות says:

    … [Trackback]…

    […] Informations on that Topic: garvis.ca/2012/06/20/boot-from-vhd/ […]…

  8. amir toronto says:

    … [Trackback]…

    […] Read More: garvis.ca/2012/06/20/boot-from-vhd/ […]…

  9. read here says:

    … [Trackback]…

    […] There you will find 76245 more Infos: garvis.ca/2012/06/20/boot-from-vhd/ […]…

  10. … [Trackback]…

    […] Read More: garvis.ca/2012/06/20/boot-from-vhd/ […]…

  11. … [Trackback]…

    […] Informations on that Topic: garvis.ca/2012/06/20/boot-from-vhd/ […]…

  12. […] Creating a Multi-OS Environment with Boot from VHD (garvis.ca) 43.484429 -79.685767 Rate this:Share this:ShareEmailPrintTwitterFacebookLike this:LikeBe the first to like this. […]

  13. dsleeman says:

    Hey Mitch – great article, and I’m in the process of migrating my main laptop to Windows 8, and I want to create a VM for my old Win7 install and be able to boot to VHD for that image (creating it with Rusinovich’s disk2vhd utility).

    Is the process the same if Win8 is the host? (i.e. using imagex.exe, etc.)

  14. Trying it Out: How to prepare to test your new operating system…

    This is a really exciting season for IT Pros across Canada.  Last week Microsoft released Windows…

  15. […] partition and then install the OS to a VHD.  I outline the steps to do this in my article ‘Creating a Multi-OS Environment with Boot from VHD’ several months ago.  If your host OS is Windows 8 then don’t worry… the steps will work […]

  16. Shawn Okerstrom says:

    Mitch, I tried this configuration for getting a bootable Windows Server 2012 environment on my notebook. The host operating system is Windows 7 Professional 64-bit but when I got all done & try to boot the Windows 2012 installation I get a Boot Manager error in the file winload.exe. It gives a status of 0xc0000482 and an explanation of “Windows cannot verify the digital signature for this file”. The Windows 7 installation still works fine but I cannot seem to find any useful information to fix this error that would pertain to the booting of a VHD. I suspect that it might be the Windows 7 Boot Loader not knowing about Windows 2012 – would there be a way to upgrade the boot loader to the 2012 version if there is one?

    Please let me know what you think. Thanks in advance.

  17. nagesh says:

    Is it possible to go for dual boot using VHD on a OEM SLP windows 7 home premium? Will it impact my winodow 7 activation? I read the activation for OEM:SLP OS is based on the motherboard and bios. .

    • Mitch Garvis says:

      While I do not believe it will impact your activation, I am not a licensing expert and cannot make any promises. With that being said, either of the dual-boot operating systems will still believe they are running directly on the motherboard. -M

    • inno says:

      Hi. Tried using the tools and getting an application error message.”The application was unable to start correctly….”

  18. techinitiate says:

    I realize this must be a very old version of multi-booting from three Windows OSes at the same time, but I’m having trouble editing my boot configuration through the command line, which always returns an error specifying a problem “setting the element data.” Having no idea about that, I Googled around a bit and found it was connected to the fact that my disk was dynamic, and my disk actually is dynamic. However, I’m not sure whether that is the actual reason, since the source wasn’t authentic (aka Yahoo Answers) Would you please clarify if this is the actual reason, or is there another one?

    • Mitch Garvis says:

      Hi Techinitiate,
      There is a program called EasyBCD that will help you with this… while it doesn’t really show you what it is doing, it is a much easier way to configure your dual-boot. Good luck! -M

      • techinitiate says:

        Thank you for your help Mitch! But I’ve used it before and the boot configuration won’t change, as I find every time I refresh the BCD Store.

      • Mitch Garvis says:

        Wow that is interesting… I have used it several times without a problem. Are you remembering to press SAVE? (I know… just in case)

      • techinitiate says:

        Yeah I do and it does return a message at the bottom of the window saying “Entry successfully added to boot menu”. When I refresh the store, the boot device keeps returning to C: which is my first hint that something’s wrong. Just to confirm, I reboot, and then my bootmgr returns an error telling me that it can’t find the specified file.

      • Mitch Garvis says:

        I see… I wish I could look over your shoulder and try to troubleshoot this one for you… sorry! :(

  19. […] via Creating a Multi-OS Environment with Boot from VHD. […]

  20. […] Creating a Multi-OS Environment with Boot from VHD. […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Tweet Tweet…

Follow The World According to Mitch on WordPress.com
%d bloggers like this: