Ramblings from another nerd on the grid
Executive Summary
Boot from VHD is a new technique for installing and maintaining operating system environments. Unlike virtual machines, the operating system that is running from a “boot from VHD” environment is using the actual hardware instead of emulated hardware. This means a developer could easily use WPF and the full GPU processing power of a high end graphics card. In another scenario, this technology makes it easy to setup and run Windows Server 2008 R2 with the Hyper-V role, thus supporting 64 bit virtualization workloads.
The Virtual Hard Disk (VHD) is the container for the installed operating system. Because everything is inside a single file, there are a number of benefits that can be realized for data center server environments, as well as managed desktop environments. The following article dives into the technical details of implementing two operating systems. Both are installed in a VHD file and can easily be booted by selecting the preferred environment at power on. This could easily be scripted and automated.
The Installation Foundation – Windows PE
The Windows Preinstallation Environment (WinPE) has been updated for Windows 7 and Windows Server 2008 R2. One of those improvements is the ability to use a Virtual Hard Disk (VHD) file as the target for an installation of the operating system (OS).
This has some interesting implications. Booting from a .VHD file that contains an entire OS seems rather magical. I mean think about it. You go to look at a hard drive and there’s a single file but Windows Server 2008 R2 is installed inside it. This would certainly simplify the ability to boot your servers on a completely new environment with little effort. This is going to turn change management on its ear.
The same is true for the desktop OS, Windows 7. You can install Windows 7 inside a .VHD file. Again, the OS is installed inside a single file and thus makes it rather easy to move or change out and bring up a completely different version of the environment. This will make test environments for developers super easy to construct and test discrete sets of applications or components.
One thing that is not well known is how easy it is to create the initial .VHD file and install the operating system into it. The supported and documented ways are geared towards very well defined support scenarios. You can see the supported scenarios in the Windows Automated Installation Kit (WAIK). Most people have been reluctant to take the time to learn this because it involves the use of imagex captures and applies.
What if you could install with just the DVD?
You can. All you need is a hard drive with disk space and the DVD for Windows 7 RC or Windows Server 2008 R2 RC. In fact, when I was investigating the tools for this article I used a brand spanking new Hitachi 2.5” 320GB 7200rpm hard drive and both DVDs to create a dual boot environment. Nothing more. And it’s much simpler than I thought. The key is WinPE and DISKPART. Here is the screencast demonstration of the tools in action.
The Screencast Video – 23 minutes – Win7 and R2 Dual Boot via VHD
The Command Sequence Used in the Video
Other References and Articles
Windows Automated Installation Kit (WAIK) for Windows 7 and Windows Server 2008 R2 RC – get it @ http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=60a07e71-0acb-453a-8035-d30ead27ef72. This is the bible for the supported methods of using “Boot from VHD”. Windows Virtualization Blog – see their VHD boot post at http://blogs.technet.com/virtualization/archive/2009/05/14/native-vhd-support-in-windows-7.aspx. Particularly interesting is the performance area of the post. Knom’s Developer Corner – another nice post at http://blogs.msdn.com/knom/archive/2009/04/07/windows-7-vhd-boot-setup-guideline.aspx.
Windows Automated Installation Kit (WAIK) for Windows 7 and Windows Server 2008 R2 RC – get it @ http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=60a07e71-0acb-453a-8035-d30ead27ef72. This is the bible for the supported methods of using “Boot from VHD”.
Windows Virtualization Blog – see their VHD boot post at http://blogs.technet.com/virtualization/archive/2009/05/14/native-vhd-support-in-windows-7.aspx. Particularly interesting is the performance area of the post.
Knom’s Developer Corner – another nice post at http://blogs.msdn.com/knom/archive/2009/04/07/windows-7-vhd-boot-setup-guideline.aspx.
So What’s Next ???
Tomorrow I am going to backup my existing Windows 7 production hard drive. Windows 7 is installed in the traditional fashion on a 200GB drive right now. I am going to restore the backup to a larger disk then install Windows Server 2008 R2 RC into a .VHD and test mixing them. That’s a bit of a hybrid and one I think a lot of developers might be interested in. It would certainly demonstrate you can have a traditional implementation of your production OS, but flip to any other Windows Server 2008 R2 or Windows 7 testbed very easily. I’ll follow-up here or another post when I get that implemented. Enjoy.
[UPDATE for 5/23/2009] As I indicated just above, I wanted to run an extension of the test I recorded. I backed up my 200GB Windows 7 RC environment then restored it to a 320GB drive. After that, I booted from the Windows Server 2008 R2 RC DVD and created a bootable VHD with R2 inside. The VHD is stored in a folder at the root of my 320GB disk. The R2 setup program fixed up the bcdstore area and I now have a dual boot hybrid. Windows 7 is installed in the traditional manner. R2 is booting from the VHD. Both are available on the selection menu at power up. Interesting stuff for sure.
[UPDATE for 5/25/2009] Since I received a couple of questions out of band on how I captured the demo, let me explain. The demo was captured using Camtasia v6.0.2. The demo was a Hyper-V virtual machine, not native hardware. I had mentioned that in some of the preliminary takes but I guess I didn't make that clear in the final take. Therefore, the booted OS in the screencast is actually using the emulated hardware of the virtual machine. Everything you see in the demo works on my native hardware, a Lenovo ThinkPad T61p.
One other thing, the VHD that is being booted from will expand to the maximum size specified at creation. It will revert to the used size when you shut it down. Keep this in mind because that buffer must exist at boot time or else.
[UPDATE for 6/14/2009] Although this article was originally written using a blank hard drive, I have received a few suggestions for adds, so here they are.
I have a brand new laptop coming in this week and love this setup. I would like to follow it exactly as I will be using Windows 7 and Server 2008. I may do one thing differently and that's to partitiion my drive into two. On one side I want to install Vista for apps I use that are not supporting Windows 7. On the other primary partition I want to replicate what you have shown here. From the comments I do not beleive this will be an issue as I will have a primary Windows Vista (non vhd) partitiion and then a second partition with the bootable vhd files on it.
(My laptop is also upgradable to have 2 hard drives, but for now i'll have one. Dell Precision M4400)
I think I may give the following space allocations per your :
Partition #1: 175GB (C: Drive)
Vista 64 (Native)
-Everyday applications & tools, possibly a game or two
Partition #2:
Windows 7 - 50GB (W: Drive)
- Just for fun, for now
Server 2008 - ~95GB (S: Drive)
- Will have SharePoint 2007 installed and related tools
How does this sound, any feedback?
sir,
i am interesting your screencast video win7 to win2008 vhd how can i download your blog video for my tutorial installation.
thanks
ed
When the VHD is booted it has full access to all of the hardware on the machine. Does this include the disk/partition it resides on? How is security managed on the NTFS partition under the VHDs?
Excellent video, maybe if someone have a way to make this native vhd with the drivers installed also run using virtual server or virtual pc.
as you can fairley predict the kind of emulated hardware virtual pc creates for you, maybe there is a way to also support it.
This way you will have a vhd on a portable hard drive which runs natively on your laptop, but also can run in a virtual enviroment on someone else's computer.
That would be pretty usefull
I just read your blog entry today, and not a moment too soon. Earlier I ran WinPE on my XP Home Edition PC and shrunk my partition so I could create a second partition to install Windows 7. Instead, when I booted the Seven DVD, I launched a PE command prompt, extended the partition back to the full size of the disk, created a VHD, and installed Seven to the VHD. Everything went smoothly and now I'm booting XP Home and Windows 7. This is a phenomenal technology; my mind reels at the possibilities. Thanks Keith!
The possibilities in the data center are mind blowing.
Or using all of the idle machines in an enterprise for coordinated computing. Push a .VHD, reboot, run a specific task, revert when done. Simple.
How do I duplicate the same vhd file in another PC (exactly same hardware) ?
Thanks, and sorry for my english.
Hi Keith.
I might have missed it. But what if I already have a vhd file with Windows 7 RC installed in it, which I have created vith Virtual PC and just want to copy that file to a new machine as the boootable vhd file? How would I install the PE environment, create the virtual disk partition and install that file (copy) instead of doing a complete operating system install? Where may I look for steps to do this?
Thanks and regards
This is REALLY stupid, but... if using the Windows Server 2008 disk, it NEEDS to be the Server 2008 r2 RC and not the Server 2008 w/ SP2 disk. (The file date you're looking for is 4/30/09 and not 5/11/09.
Obviously Casey didn't read the article. I said R2. R2 has meaning. R2 is 64 bit only, has DirectAccesss, Boot from VHD, etc.
Casey, next time you want to call someone stupid, get your facts straight first.
I thought it was pretty obvious that I was calling MYSELF stupid. I thought the article was put together very well, and very easy to understand. What I had to say was a stupid addition to your article, and my hope was that I could prevent somebody from making the same mistake I made.
Oops. I thought you were calling me stupid. I'm the only one allowed to do that (and do it frequently).
Yep, the R2 or Win7 disk is one of the requirements because of the updated version of WinPE, Diskpart, etc.
Peace !!!
Good Article. I have been using the VHD Boot Windows7 for sometime. But recently y organization decided to encrypt all our Laptops with pointsec software. From then on, I am not able to boot with the VHD Image. It Just gives "Blue screen". Any thoughts on this issue?
Thanks in Advance,
Jibu
Good Article. I have been using the VHD Boot Windows7 for sometime. But recently my organization decided to encrypt all our Laptops with pointsec software. From then on, I am not able to boot with the VHD Image. It Just gives "Blue screen". Any thoughts on this issue?
Can you use the diskmanagement GUI in windows 7 to create a VHD and install directly onto that?