Boot2VHD-Part 1-Overview of Native Boot To VHD
Native Boot To VHD (Boot2VHD) - Everything You Need To Know…
In this multi-part video series we will dive deep into a the new virtualization feature built into Windows Server 2008 R2 and Windows 7. It is called Native Boot To VHD (AKA: Boot2VHD). This is the one virtualization platform that allows virtualization inside of the virtualized machine. Yes, you can run Hyper-V or Virtual PC from inside a Boot to VHD machine. There are lots of use cases for this technology; we will cover many of them. Just dual boot your machine to a drive that is a VHD file.
It is very clean, as the entire OS is in a VHD file. Having the OS fully encapsulated in a VHD means no changes are needed to partitions, and there is no confusion as to what files are for what OS. We will look at how to deploy it in different scenarios and we will take a deep dive into the boot technology (BCDEdit) that makes this new feature possible. Upon finishing this video series you will know how to setup a system with Boot To VHD. You will be able to deploy Windows 7 or Windows Server 2008 R2 in a VHD on a machine that is already running a new OS, or on a machine with nothing on it yet (bare metal). We even go through the process of having to add the raid drivers for the disk while setting up the boot to VHD.
TechNet Video: (Part 1) Overview of Native Boot To VHD
Download
WMV Download | WMA | MP3
Transcript: Details of Coverage of this Video
· Introduction to Native Boot To VHD (Boot2VHD)
o The VHD file format has become the standard for drive images. They can be Fixed or Dynamic. Fixed are larger because they are automatically expanded to take up the full capacity of VHD regardless of how much free space might be available. This makes them a tad faster but much slower to deploy because it takes longer to move such large files. Dynamic disks are much smaller. They are only as big as the actual space used on the disk plus some header and footer data. This makes them much faster to deploy. The VHD’s used for Boot to VHD is the same file format as is used in Virtual PC, Virtual Server and Hyper-V.
o Windows 7 not supported: Starter, Home Basic, Home Premium, Professional
o Server 2008 R2 not supported: Foundation Edition
o There are a number of tools you can use to work with Boot to VHD. Many of them are simply different ways of doing the same thing. We will look a DiskPart, the Disk Management MMC and BCDedit in a bit more detail.
o Transition: Before we get into that, let’s take at some of the benefits of Boot to VHD
o Tools more details …
o DiskPart A command-line tool that you can use to create, attach, and detach VHDs. You can also perform more advanced tasks like compacting, expanding, and merging VHDs. For more information, see DiskPart on Microsoft TechNet (https://go.microsoft.com/fwlink/?LinkId=128458).
o Disk Management A Microsoft Management Console (MMC) snap-in that you can use to create, attach, and detach VHDs.
o BCDEdit A command-line tool that you use to manage boot configuration data (BCD) stores. For more information, see BCDEdit on Microsoft TechNet (https://go.microsoft.com/fwlink/?LinkId=128459).
o BCDBoot A command-line tool that you can use to manage and create new BCD stores and BCD boot entries. BCDBoot can be used to create a new boot entry when configuring a system to boot from a new VHD. For more information, see BCDBoot Command-Line Options on Microsoft TechNet (https://go.microsoft.com/fwlink/?LinkID=155166).
o Deployment Image Servicing and Management (DISM) A command-line tool that you use to apply updates, drivers, and language packs to a Windows image. For more information, see Deployment Image Servicing and Management Technical Reference on Microsoft TechNet (https://go.microsoft.com/fwlink/?LinkId=155029).
o Windows Hyper-V Manager An MMC snap-in that supports VHD image creation. You can specify the type and size of VHD and install Windows from a CD or DVD, or from an ISO Image file. The Hyper-V Manager is only available on computers that are running Windows Server 2008 or Windows Server 2008 R2 with the Hyper-V role installed.
o Sysprep A tool that enables you to remove user and computer-specific data from the operating system image. This enables you to capture the image and deploy it to other computers. For more information, see Sysprep Technical Reference on Microsoft TechNet (https://go.microsoft.com/fwlink/?LinkId=155027).
· Benefits and Performance
o With Boot to VHD you are NOT running on a virtualization platform, you are running directly on the hardware using native drivers for devices. The only synthetic driver will be for the VHD storage.
o Since you are running on native hardware, you CAN run a Windows Virtualization Platform inside your VHD. You can run Virtual PC or Hyper-V under a Native Boot VHD. From a performance standpoint, you are better off running the VHD’s in your virtualization platform on a physical disk instead of a virtual disk.
o You can deploy exactly the same VHD file to either physical or virtual hardware. Boot to bare metal or on a Hyper-V host and go between the two if you need to.
o You can use the tools we all know and understand to manage VHD‘s
o Multiple boot typically means separate partitions which can result in waisted disk space as well as confusion. Boot to VHD gives us ISOLATION between partitions without wasted space. Plus if you store your data on the physical disk instead of the VHD, you can easily share data between machines.
o Re-uasbale environments are typically used for things like development or testing, they can be very quickly deployed and they are very easy to reset to their original state.
o Your disks can be Fixed, dynamic and even differencing. The parents can also be differencing disk which means it supports differencing chains.
o You will be pleasantly surprised at the incredible performance we get out of Boot to VHD. In fact, let‘s drill down a bit more on performance.
o A look at the I/O Queue Depth: The read performance of a VHD regardless of size of packet or random vs sequential reads, is identical to the native disk performance.
o When writing to dynamic disks, there is a very slight degradation in performance. This is so slight that in most cases, it will not be noticeable to the users. If you need rocket performance, you can use Fixed VHD or Passthru disks. If you do not need every ounce of performance, your biggest bang is with Dynamic as the disk utilization is far superior.
· Inside look at Boot to VHD Partitions
o Your physical (non-VHD) installation of windows will show up as the physical C: drive. Also, the pagefile will be on this physical volume.
o When you Boot to VHD the Physical drive will be changed to the D: drive and the VHD drive will become the C: drive
o Note that the physical D: drive will show available space as if the VHD is fully expanded even though it may not be. If you try to boot a dynamically expanding VHD on a physical disk that does not have the capacity, they system will blue screen when it tries to load the disk driver!
o These different disks are shown in Disk manager as different disks. The Blue icon shows that it is a VHD. The fact that it is the Boot and C: Drive, tells you it is a Boot to VHD. Also notice the System and Page File are on the F: drive. These are on the Physical Disk, not the VHD.
· Common Scenarios
o Offline Image Management or Disk Manager – to activate the VHD file and access it via a drive letter rather than as a –VHD file.
o As mentioned previously the same VHD can be used in both physcal an virtual environments – may be more useful for server images in data centers where it is not always known where a server will be installed.
o Boot new hardware without installing an OS
o Support multiple local images (for different tasks or workloads) - Demo Environments, Training Environments, etc.
o Host images centrally for copying where required.
o Use Windows Deployment Services (WDS) to deploy VHD images via network boot (PF12).
· Installing … OS Media or Network Boot
o Format Media (if doing bare metal install)
o You should be on the “Where do you want to install Windows?” screen of the installation press Shift-F10 to drop to command prompt
o Find installation drive (dir c:, dir d:, dir e:, etc)
o Diskpart
o Create vdisk file=e:\BootDemo.vhd type=expandable maximum=40000
o Attach vdisk
o Exit
o Click “Refresh” button
o Select “New Drive” and perform normal installation
o Using this method, the BCD will be updated automatically
· Preparing for Native Boot and BCDEdit
o Now that we have looked at installing windows to a VHD let‘s look at how to tweak the boot configuration and/or go through manually adding existing VHD‘s to a machine.
o You need to make a note of the GUID when you copy. If you do not, you can obtain it by doing a BCDEDIT alone. If no GUID value is entered for the {current} is assumed and you may just mess up your boot menu all together. So... Please be careful with this very powerful tool. If you do by chance royally mess things up, you may want to check out
o In order to use Boot to VHD you have to have the Windows 7, Windows Server 2008 R2 Boot Manager running on the machine. If you are running Windows Vista and want to use Boot to VHD to run a Windows 7 vhd on the same machine, you can simply install the boot manager by copying it over from a valid windows 7 installation.
o You can create a vhd using any number of different tools that perform that function
o Xxxx
o
o BCDEdit is a tool that allows you to change the Boot Configuration Data on a Windows 7 boot managed machine. You can do things like Copy existing entries, edit entries, change the display order, change the timeout, change the default entry, turn on HAL detaction, etc. I have a bunch of examples of proper syntax here to make it easier for you to get up to speed quickly
· An Inside Look at BCDEdit
o If host system is Vista SP1:
§ Replace Bootmgr and BcdEdit.exe with Windows 7 versions (BCDBoot)
o Create bootable VHD file
§ Disk Manager, Hyper-V Manager, ImageX, SCVMM, DiskPart,Etc
o Copy bootable VHD to a directory on the host system
§ (e.g. ‘c:\vhd\BootWin.vhd’)
o Use BcdEdit to copy the existing boot entry (from administrative cmd prompt)
bcdedit /copy {current} /d “Windows VHD Boot”
o Look at the new entry
bcdedit /v
o Use BcdEdit to Edit the VHD system
bcdedit /set {GUID} device vhd=[c:]\vhd\BootWin.vhd
bcdedit /set {GUID} osdevice vhd=[c:]\vhd\BootWin.vhd
bcdedit /set {GUID} detecthal on
o Use BCDEdit to change the description, default start item, menu order, timeout, etc.
bcdedit /set {GUID} description “New Menu Description Goes Here!”
bcdedit /default {GUID}
bcdedit /displayorder {GUID_1} {GUID_2}
bcdedit /timeout 10
o If using virtualization on the system… (Make sure you cold boot after making changes)
Enable Virtualization in BIOS
bcdedit /set {GUID} hypervisorlaunchtype auto
o If you make a mistake while “playing” with BCDEdit seeServer 2008 R2 or Windows 7 System Will NOT Boot After Making Changes To Boot Manager Using BCDEdit
· Limitations
o Native Boot is only for Windows 7 and 2008 R2
o Native Boot does not support Hibernation
o Sleep mode is supported
o Native Boot does not support Bit Locker
o No Over Allocation of Disk Space *
o No “Nested” boot to VHD
o Maximum size of dynamic VHD = 2TB (2048 GB)
o Parent of Differencing disk must be on same volume
· VHD Boot Guidelines
o Native VHD boot requires Windows 7 Boot Manager (Bootmgr) and BCDEdit utility
o Use BCDboot.exe from attached VHD
o Pagefile and boot manager are outside Virtual Hard Disk (VHD)
o Dynamic VHD expanded during boot
o Plan physical disk free space accordingly
o Store user data outside of the OS VHD
· Limitations
- Native Boot is only for Windows 7 and 2008 R2
- Native Boot does not support Hibernation
- Sleep mode is supported
- Native Boot does not support Bit Locker
- No Over Allocation of Disk Space *
- No “Nested” boot to VHD
- Maximum size of dynamic VHD = 2TB (2048 GB)
- Parent of Differencing disk must be on same volume
· VHD Boot Guidelines
- Native VHD boot requires Windows 7 Boot Manager (Bootmgr) and BCDEdit utility
- Use BCDboot.exe from attached VHD
- Pagefile and boot manager are outside Virtual Hard Disk (VHD)
- Dynamic VHD expanded during boot
- Plan physical disk free space accordingly
- Store user data outside of the OS VHD
· Creating Differencing Disks
o Wouldn’t it be a great feature if you could restore an operating system to its default configuration within a couple of minutes? This can easily be achieved with the help of VHD differencing disks. Differencing disk in Hyper-V or Microsoft Virtual PC are in essence the same as with Windows Native VHD boot. The disk has a parent – child relationship where all new blocks are written to the child disk, leaving the parent disk to its preconfigured state. This enables the possibility of a quick restore by replacing the differencing disk and re-enabling the parent – child relationship. Essentially we will use the same steps as before, create VHD’s, and setup the parent – child relationship. As the final step we will need to alter the boot configuration data store to be able to boot off the differencing disks. Use the following steps to create the VHD’s and setup the relationship.
o Create the VHD’s
diskpart
create vdisk file="D:\WIN7_Diff0.vhd" parent="D:\WIN7.vhd“
exit
This takes care of creating the VHD’s and setting up the parent – child relationship. To be able to boot to the differencing disk, the BCD store will need to be updated to reflect our intended changes.
o Update the BCD store.
BCDEdit.exe /set {GUID} device VHD=[D:]\Win7_Diff0.vhd
BCDEdit.exe /set {GUID} osdevice VHD=[D:]\Win7_Diff0.vhd
· Thin Provisioning – Be Very Careful
o Thin Provisioning allows you to not have the vhd auto-expand. However, if the underlying disk runs out of space you risk VHD corruption which could destroy your entire VHD.
o Disk expansion happens when driver is loaded
§ Cannot suppress expansion during Installation
§ Stop Error if not enough physical space (Blue Screen)
o Registry entry will prevent the disk from expanding to its full size. Open the registry editor, browse to
§ The location that’s displayed below and alter the value to “4”.
§ [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\FsDepends\Parameters]
§ "VirtualDiskExpandOnMount"=dword:00000004
o Strongly Recommend You NOT do this!!!!
o IF you run out of disk space, you will likely corrupt your VHD!
· Resources
o Dan’s Blog
o https://blogs.technet.com/danstolts
o http :// blogs.technet.com/danstolts/pages/eventresources.aspx
o https:// blogs.technet.com/danstolts/Contact.aspx
o What's New for IT Pros in Windows 7
https://technet.microsoft.com/en-us/library/dd349334(WS.10).aspx
o What's New in Virtual Hard Disks
https://technet.microsoft.com/en-us/library/dd440864(WS.10).aspx
o Windows(R) Image to Virtual Hard Disk (WIM2VHD) Converter
https://code.msdn.microsoft.com/wim2vhd
· Tools & Resources
o Appendix: Tools, Scripts, and APIs.
o The following tools are included in Windows 7 and Windows Server 2008 R2:
o DiskPart A command-line tool that you can use to create, attach, and detach VHDs. You can also perform more advanced tasks like compacting, expanding, and merging VHDs. For more information, see DiskPart on Microsoft TechNet (https://go.microsoft.com/fwlink/?LinkId=128458).
o Disk Management A Microsoft Management Console (MMC) snap-in that you can use to create, attach, and detach VHDs.
o BCDEdit A command-line tool that you use to manage boot configuration data (BCD) stores. For more information, see BCDEdit on Microsoft TechNet (https://go.microsoft.com/fwlink/?LinkId=128459).
o BCDBoot A command-line tool that you can use to manage and create new BCD stores and BCD boot entries. BCDBoot can be used to create a new boot entry when configuring a system to boot from a new VHD. For more information, see BCDBoot Command-Line Options on Microsoft TechNet (https://go.microsoft.com/fwlink/?LinkID=155166).
o Deployment Image Servicing and Management (DISM) A command-line tool that you use to apply updates, drivers, and language packs to a Windows image. For more information, see Deployment Image Servicing and Management Technical Reference on Microsoft TechNet (https://go.microsoft.com/fwlink/?LinkId=155029).
o Windows Hyper-V Manager An MMC snap-in that supports VHD image creation. You can specify the type and size of VHD and install Windows from a CD or DVD, or from an ISO Image file. The Hyper-V Manager is only available on computers that are running Windows Server 2008 or Windows Server 2008 R2 with the Hyper-V role installed.
o Sysprep A tool that enables you to remove user and computer-specific data from the operating system image. This enables you to capture the image and deploy it to other computers. For more information, see Sysprep Technical Reference on Microsoft TechNet (https://go.microsoft.com/fwlink/?LinkId=155027).
o The following tool are included in the Windows Automated Installation Kit (Windows AIK):
o ImageX A command line tool that enables you to capture, create, modify, and apply Windows images. For more information, see ImageX Technical Reference on Microsoft TechNet (https://go.microsoft.com/fwlink/?LinkId=155340).
Links to All Parts of This 4 Part Video Series Coming This Week
· TechNet Video: (Part 1) Overview of Native Boot To VHD
· TechNet Video: (Part 2) Load OS to VHD On Bare Metal
· TechNet Video: (Part 3) Load OS on VHD with OS already Installed on Metal
· TechNet Video: (Part 4) BCDEdit is the Magic – Deep Dive Boot Configuration Manager
Ping Dan Stolts on Twitter @ITProGuru (https://twitter.com/itproguru)
Visit Blog: https://ITProGuru.com
Other posts that may be of interest:
· How To Automatically Create BCDEdit Data For A Boot2VHD File On Your Windows 7 or Windows Server 2008 R2 Machine
· Blue Screen Booting to VHD–You May Be Out Of Space On The Underlying Drive
· If you make a mistake while “playing” with BCDEdit seeServer 2008 R2 or Windows 7 System Will NOT Boot After Making Changes To Boot Manager Using BCDEdit.
Comments
Anonymous
January 01, 2003
Dan, this is awesome. Thank you.Anonymous
January 01, 2003
Greetings rainer, I will try to answer your questions... Let me know if I missed any part of it. -- "VHD you must have enough capacity on the underlying disk to fully expand the VHD" means that the underlying disk (the disk the VHD is sitting on) does not have enough capacity to fully expand the drive. It NEEDS 100% of the allocated disk capacity of the VHD. If the VHD has a 97gb drive, it will need 97gb + a bit more available to boot the machine. it does not use actual size when expanding, it uses maximum size. You can shrink the size of a VHD pretty easily. I did a blog post on how to do that a few months ago. -- When the system boots (when the disk driver is loaded during the boot process) the disk driver tries to grab enough capacity to "lock out" other programs or devices from using that space. NOTE: it does not look at the amount of space USED... It Looks at total capacity of the drive when it loads the drive. As far as I can tell, this was done for two reasons:
- Make sure there is enough capacity to add upto the maximum capacity of the driver
- Performance. Not having to change the physical size in the host OS every time the drive is expanded cuts down on disk I/O and processing power. -- You can bypass this normal way of doing things by following the "Thin Provisioning – Be Very Careful" instructions which are pretty close to the end of the video. -- The extra 100mb partition that is created is a system partition that is used by Windows 7. In the case of a boot2VHD this partition is not used. The partition is mostly there for compatibility with advanced features like BitLocker. Bitlocker is not available in Boot2VHD anyway. I am not certain what happens if you delete it. However, even if you do delete it, I am pretty sure it would not give that 100mb back. It would just show as 100 MB of unallocated space on the existing Drive. Because it is such a small amount of space (100MB) it is best just to ignore it. -- To get beyond the bluescreen, delete some files (or move them to a USB drive) which you can do by booting from a Windows 7 DVD and using Shift-F10 to drop to a command prompt. You have to be able to boot into the Windows 7 VHD in order to adjust the registry settings that I talked about in Thin Provisioning. Hope this helps!!
Anonymous
August 28, 2011
great information. thanks for sharing.Anonymous
August 30, 2011
The comment has been removedAnonymous
November 12, 2011
Wow -I have been getting to grips with this technology recently, and wish I had seen this overview to start off with - very comprehensive! ThanksAnonymous
June 17, 2015
The comment has been removed