<

Go Premium for a chance to win a PS4. Enter to Win

x

Boot from VHD

Published on
13,920 Points
6,320 Views
6 Endorsements
Last Modified:
Windows 7 Ultimate and Enterprise (and 2008 R2) introduced a new feature you may not be aware of - Boot from VHD.  

Boot from VHD (or what Microsoft refers to asNative Boot allows you to install Windows to a VHD (Virtual Hard Disk) file that is typically used with Microsoft Virtualization technologies, such as Virtual PC, Virtual Server, and Hyper-V.  To be clear, you are NOT running a full virtual machine using Boot from VHD, you are simply installing to a file that is appearing to be a hard disk (you ARE virtualizing the hard disk).  In some ways, this is like the old Double Space of MS-DOS or Stacker compression utility if you go back that far (but without the compression).

Because you are JUST virtualizing the hard disk, you have the advantage of having direct access to all the hardware on the system (so long as it doesn't involve disk).  Meaning if you have a high end graphics card, you can use that high end graphics card, scanner, or anything else.

Booting to a VHD has certain benefits and drawbacks.  Some of the benefits include:
Direct hardware access for everything other than the hard drive
Allows multibooting without repartitioning
Easy to upgrade your hard drive.  You can just copy the VHD to the new drive, usually very quickly as there should be no permissions issues and it's just one big (hopefully contiguous) file that can be copied (restoring the boot ability may be a little more tricky; I've never had to do it).

Most of the drawbacks will have little impact on those who would otherwise want to consider using boot from VHD.  Nevertheless, they include:
When booted to a VHD-installed version of Windows, it disables your hibernation ability.
Booting to a VHD will reduce overall disk performance (though for everyday use, not significantly in my experience).
Due to the VHD size limit of 2040 MB (just shy of 2 TB), the maximum disk size is essentially 2 TB (there is no GPT option.  Though this may be changing with Windows 8 as Microsoft is extending the VHD specification to go beyond 2 TB with VHDX).

There are several scenarios where booting to a VHD can be useful:
Consultants who need installs specific to each client
Beta testing new versions of Windows and/or service packs directly (for the most part) on your hardware (example, I have Windows 8 and Windows 8 server installed to VHDs on my laptop)
Developers who may need unique installs for their work and have scenarios where a true virtual machine just won't work.

Tips, Gotchas, and FYIs
The Windows 7 Experience score cannot be calculated because the drive is emulated.
Hibernation is disabled, so you cannot hibernate your laptop.  However, if you expect to be in one given install regularly, you may be able to hibernate by placing that installation directly on the hard drive and putting subsequent alternate installations in VHDs.
When you boot from a VHD, the drive the VHD is stored on will appear and it will appear to have the entire size of the VHD used.  For example, if you create a 200 GB dynamically growing VHD and boot from it on a 250 GB, the physical drive will appear in the booted operating system as D: with 200 GB used just by the VHD.  But if you then boot from an OS directly installed on the drive, that same VHD will now show it's actual size.
Don't let the combined size of the files on the drive plus a maximum size of a dynamic VHD exceed the size of the drive.  This will cause a problem as the dynamic VHD, as noted above, will appear to take the full maximum size when booted into that OS.  It actually does as far as Windows is concerned, so if other files or VHDs sum to be larger than the VHD of the OS you're booting into, that's a problem.
When booted to a VHD, the pagefile is NOT created in the VHD, it's created OUTSIDE the VHD on the physical drive (typically drive D:).  When booting, keep this in mind in your disk space calculations with the above point.
Ideally, you want to use a Fixed VHD and not a Dynamic VHD.  This is to help ensure the VHD file itself doesn't fragment as it grows.  The Dynamic option is tempting and certain circumstances may require it, but be aware that over time, this may cause a more significant fall off in performance.
Just because it's in a VHD already doesn't mean you can make it into a Virtual Machine.  MAYBE you can, but as far as Windows would be concerned, you changed EVERYTHING -- a virtual machine is like putting a hard drive into a completely different computer.  You'll likely have to re-activate (assuming you can get it booted) and you certainly don't want to try to go back and forth between a VM and booting to the physical hardware (and the same can be said trying to turn a Virtual Machine's VHD hard drive into a physical install running from the VHD).
You cannot nest VHD files - creating a VHD within a VHD and booting to that is not supported.
BitLocker cannot be used in conjunction with a booted operating system.  If you enable bitlocker on the drive storing the VHD, you won't be able to boot.  And you cannot encrypt the operating system (drive) that is the VHD file itself.
Dynamic disks are not supported, either as the format of the VHD when mounted in an operating system or as the storage location of the VHD.
You cannot store VHDs on a network share and boot them from there.
You cannot boot older operating systems using this method (from everything I've read; I haven't personally tried).

How To
Installing Windows 7 and Server 2008 R2 (and Windows 8) to a VHD is very easy.

1

Boot from your Windows 7 installation media and proceed to the point that you are asked to select where you want to install Windows.

2

Press Shift-F10 to bring up a command prompt

3

Enter the following commands in the command prompt. You can (and probably should) change the paths and file name used for the VHD.  Obviously, you want something on the C: drive, but you can device what you want to call it.
a) Start the diskpart command line utility by typing DISKPART and pressing enter.
b) Create a VHD file to use for your operating system installation (you can 
   skip this if you already have one created that you want to use). 
   CREATE VDISK FILE=C:\TEMP\EXAMPLE.VHD TYPE=EXPANDABLE MAXIMUM=1000 
   (Type could also be FIXED; the MAXIMUM is referring to Megabytes (MB))
c) Tell diskpart which VHD file you want to apply the subsequent commands to by 
   running the command SELECT VDISK FILE=C:\TEMP\EXAMPLE.VHD
d) Instruct diskpart to attach the drive to the system (this is akin to plugging 
   in the USB cable to an external hard disk)
e) Quit diskpart by typing EXIT.

Open in new window

Command Line to Create a VHD in Win7 Setup

4

Close the command prompt and click the word/button Refresh on the disk selection page of the Windows setup wizard.  The newly created and attached VHD file should appear as a new drive available to the system.  Click on the VHD disk as it appears in the setup wizard so that it is selected as the disk where you want to install Windows. You may notice a warning that says Windows cannot be installed to this disk. (Show details) - you can ignore this warning.

5

Continue with setup normally.
More Reading
Microsoft TechNet - Understanding Virtual Hard Disks with Native Boot
A TechNet Blog Posting by Aviraj Ajgekar - Windows 7 Boot from VHD - includes links to a 3-part series on the topic.
BenkoBlog from MSDN - Creating a Boot from VHD in Win7
6
Comment
Author:Lee W, MVP
1 Comment
 
LVL 7

Expert Comment

by:ZShaver
interesting
0

Featured Post

[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

Join & Write a Comment

This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
The viewer will learn how to successfully download and install the SARDU utility on Windows 7, without downloading adware.
Suggested Courses

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month