As I wrote in some of my earlier articles, Windows 7 and Windows Server 2008 R2 can be booted from VHD file without need to be installed on "real" physical disk. This is great option for testing or even deploying multi boot computers to users. Possibilities are endless.
Few days ago I decided to exploit this opportunity and to install Windows 2008 R2 RC in VHD and use it as boot option on my laptop. There are basically two ways you can do this.
First I created new virtual machine in Microsoft Hyper-V console and tried to implant it on my existing Windows 7 installation. I successfully modified boot sector to include VHD file but when I tried to boot from it I got BSOD.
Then I tried another possibility, I installed Windows 2008 R2 to VHD directly from its installation procedure. And it works great!
Here is procedure on how to do it:
Bare in mind that I already have Windows 7 installed.
-
Physical disk that will hold VHD file must be formatted (does not have to be empty, can not be USB)
-
Boot from Windows Server 2008 R2 DVD
-
When first installation dialog box appears pres SHIFT + F10 to open command prompt
-
Launch diskpart
-
At diskpart prompt enter following command create vdisk file=c:\win2k8r2.vhd type=fixed maximum=20000 (this will create VHD file of 20 GB and it will be fixed size, you can even use expandable as type. You can also change name and location of vdisk file)
-
Next, run select vdisk file=c:\win2k8r2.vhd
-
Run attach vdisk
-
Exit from diskpart and command prompt
-
When selecting partition on which to install Windows Server 2008 R2, select newly created and attached VHD partition. Ignore any warnings like "… cannot boot from this partition".
When installation finishes, you will have an option to boot from Windows 7 or Windows 2008 R2 RC. If you want to remove Windows 2008 R2 RC, all you need to do is edit boot menu with bcdedit command and delete or move VHD file.

P.S. This post is an anniversary one. It celebrates 100 th post.
Email
Print
Viewed 8,665 times.

{ 36 comments… read them below or add one }
When creating VHD, is it required to be placed on system/bootable partition? I have followed the steps, and tried some variations as well, but no matter what I do the “next” button is disabled when I select a virtual disk as a partition where I want to install OS. I can’t think of any other reason, and unfortunately my system (C:) partition is too small to accommodate one more OS..
As fas as I know, vhd file can be on any partition, as long as it is formated. Bare in mind that your hardware has to support 64 bit OS. Also, partition should not be smaller than 20 GB.
Hardware has 64bit support, as I’m running Win7 x64 on it. Partition is all fine, formated and all, as I have other files on it. And I have tried with partition of 30.000 MB as well.
I do have one difference compared to this “guide” post, VHD isn’t shown in setup GUI although it is attached. I have to initialize and create a partition for it to be shown. But again, “Next” is grayed out.
I have also just noticed that error I get is actually two separate errors/warnings in one text.
First one is virtual disk related-> “Windows cannot be installed to this disk. The selected disk is a surfaced virtual disk.”
But second one could be my real problem-> “Windows cannot be installed to this disk. This computer’s hardware may not support booting to this disk. Ensure that the disk’s controller is enabled in the computer’s BIOS menu.”
So I’ll check if my secondary drive (which holds the image) is properly recognized in BIOS..
You can erase my previous post. It says clearly in your post:
“Boot from Windows Server 2008 R2 DVD”
BOOT! I ran the setup from Windows 7 yesterday.. but have been too excited by the idea to think properly
Setup is running fine now, it’s just expanding files so it should be all-ok.
Thanks!
Luka
I will leave your posts as an warning to others that are too excited.
I am glad that it works now.
Thank you for leaving this comment up… I made the exact same mistake… try number 2.
When creating VHD, is it required to be placed on system/bootable partition? I have followed the steps, and tried some variations as well, but no matter what I do the “next” button is disabled when I select a virtual disk as a partition where I want to install OS. I can’t think of any other reason, and unfortunately my system (C:) partition is too small to accommodate one more OS..
VHD file does not have to be on system/boot partition, also, please read comments by LuxZg, maybe you have same problem.
Hi
Maybe I didn’t get very well your tutorial. What is the point to boot on a vhd for testing purpose if the partition that hosts it must be formated? Wouldn’t it be the point of this feature to have multiple vhd on an existing partition/physical hard drive we can boot from?
Thanks
@paillave You can have multiple VHD files on one partition. You can have operating system on host partition or not. All your operating systems can be in VHD files. There are no limits for combinations. For example, I have Windows 7 installed directly on disk and Windows 2008 R2 in VHD file which is located on the C drive of Windows 7. Now I could copy my existing Windows 2008 R2 VHD file to D partition, “sysprep” it and have one more instance of Windows 2008 R2 to boot to. My boot menu would have 3 entries, one Windows 7 and two Windows Server 2008 R2. I use Windows 2008 R2 as second operating system for teaching purposes. I run Hyper-V in it. It is much cleaner to install OS into one VHD file than to install it as dual boot. Feel free to contact me if this explanation does not help.
What I would really like to do is run WS2008R2RC in a Virtual PC guest on Windows 7. That’s how I’ve been doing all my testing. That allows me to pause and go do other things or access the internet for information and then switch back. Is this not possible? When I try it, I get the error that my CPU is not 64bit. I do have Windows 7 installed as 32bit. I guess Virtual PC does not have the ability to emulate either?
VirtualBox will usually do this, but it’s having some other error message. Having a dual boot is much less useful than simultaneous boot. Any ideas?
Windows 2008 R2 is 64 bit operating system. Hyper-V and VMWare ESX server are the only virtualization technologies that can emulate 64 bit environment for 64 bit virtual machines. So this means that you can not install 64 bit operating system into Virtual PC or MS Virtual Server 2005. Microsoft is in process of creating Virtual PC 7, which is supposed to be Virtual Server 2005 succesor, but it is not yet available for download.
If you install Windows Server 2008 R2 in VHD file, it is very easy to remove it later on. just delete entry from boot manager in Windows 7 and that is it. Much cleaner than “normal” dual boot.
In your comment of 9/12, you mention making a copy then sysprepping, then having 3 items in the boot menu.
How did you add the addition boot entry to point to an additional VHD file? Via BCDEDIT or BDCBOOT?.
Basically, if I just put another VHD on a disk, now I want to get this added to my boot menu. Let’s assume it’s a VHD that contains either Win7 or Win2008R2 just to make it simple. What do you see as the steps to add it to the boot menu?
Thanks…
Never mind – found a great link. Last “section”
To add a native-boot VHD to an existing Windows 7 boot menu
http://technet.microsoft.com/en-us/library/cc731662%28WS.10%29.aspx
Thanks for the link Shawn C!
To those interested in creating native VHDs on systems such as Windows XP, Windows Server 2003, Windows Vista, Windows 7 etc…Take a look at this utility. This takes all the work out of setting up a dual-boot VHD environment and manages it as well.
http://www.portlock.com/products/leap_frog/
Hi,
How can I boot from an existing VHD(with XP OS already created using VPC)? Can I just edit the boot.ini and add the existing VHD in list? How?
Actually, I’ve been trying to convert my VHD into a selected physical partition. Is that possible?
Thank you in advance! =)
You can not boot Windows XP from VHD file. You can only boot Windows Server 2008 R2 or Windows 7 from VHD. The easiest way, that comes to my mind right now, to “convert” VHD to physical disk is to start your VHD in Virtual PC, use Ghost to capture OS image in Virtual PC and then deploy that image on physical computer.
I see.. I’ve tried WinImage but no luck coz it is not giving me an option to select a partition or drive letter.It just gives the option to format the whole physical drive (disk 0) and restore the content from the VHD. Anyway, I’ll try Ghost.. Should I expect to encounter a trouble on that? If yes, what are those trouble and how to resolve them?.. Thank you!..
Thanks for this post. I still don’t understand why the Windows Server 2008 R2 image I created using Hyper V BSOD’d when I tried to boot it natively. I felt better knowing I wasn’t alone in getting that behavior. I proceeded with your second option and it worked without any problems.
Hi Brian,
did you sysprep that VHD image created in Hyper-V? Bare in mind that virtual processors and IDE controllers are represented differently in virtual and physical world.
Hi, I tried to install W2008 to a VHD but I do not get Shift + F10 to show a command prompt on the first installation dialog. Pressing Shift+F10 but nothing happens! Can it be that Small Business Server behaviour differs?
Hi Jos,
SBS 2008 is based on Windows Server 2008 (http://www.microsoft.com/sbs/en/us/compare-features.aspx). Boot from VHD is available only in Windows Server 2008 R2.
Thx, Marin. I gues I have to dl R2 then…
It’s possible to boot Hyper V R2 from VHD and then run guest os in Hyper V (vhd in vhd) for teaching purposes?
Hi Noizychild,
of course you can do that. Although, I use external USB to store my VHD, because of disk space.
You give me a great solution. Thanx Marin!
Hi Marin, thanx for the great and simple way on creating a W2008 bootable VHD. I’ve been to several “how to’s” on that but they are too complicated or require too many things/tools to work. I have one question: can I move the VHD to another machine? I saw elsewhere that there is some “detecthal” option on bcdedit, maybe it can be used to that?
Hi GB,
The right way to transfer VHD to another system is to sysprep the OS after installation in VHD and start it on other computer. But that would not give you true mobility between computers since you had to sysprep it every time you move it to another machine. I did not try it with bcdedit detecthal switch. If you try it, please let me know if it works or not.
Well that’s what I did so far: my only boot was a W2K8, and I had VM’s to test SharePoint 2010, wich runs poorly on 2Gb RAM. So your tip allowed me to use all my (4Gb) RAM and CPU to run the test boot – wich I could not do using a VM on Hyper-V. I used differencing disks, wich allowed me to rollback the “damage” the tests did on the boot in a very easy way. And yesterday I reformatted my machine and got back to W7 (the USB TV receiver I bought did not work on W2K8, so I could not watch the Soccer World Cup matches at work – that’s a completely valid reason to reformat your machine here in Brazil
, well, I moved back to W7 and all I had to do to run the W2K8 boot was to duplicate the W7 boot entry and modify it to point to th W2K8 vhd – a couple of bcdedit commands, I’ll put them on my blog in case there’s anyone interested.
I’ll copy the VHD to see if it works on another machine without sisprep and post here the result.
Ok, that doesn’t work. I copied the VHD from my notebook – where it was created – to the desktop, and when trying to boot from it, all I got was a black screen and a reboot. Shame, it would be extremely useful, even more if it could be done from a USB stick… Imagine the uses for a “mobile boot”
Hi gboucha,
you should sysprep it. Regarding boot from USB stick, did you see this article: http://blog.frankovic.net/2010/06/install-windows-server-2008-r2-or-windows-7-on-usb-stick/ ?
I followed the instruction here, once I selected the Unallocated Space (the vdisk), clicked Next, it said “Setup was unable to use the existing system partition because it does not contain the required free space”, and can not move forward. I’ve tried fixed and expandable, both same issue. After I reboot back to win7, I saw the vhd file is created.
Any clue?
Hi Eric,
it seems that your partition was too small. Please read carefully instructions and try again.
I set the vfile to 100G – maximum=100000, should be big enough.
It definitely should be enough.
Well, maybe you selected the wrong one. It is very hard to help you like this. Maybe the best thing would be to try again.
{ 1 trackback }