Windows 7 – Natively Booting from a .VHD file (Virtual PC image)


[Update 15 August 2009 – Tested with Windows 7 RTM final version] 


The most important thing to keep in mind is that we currently (prior to Windows 7) cannot natively boot from any kind of .VHD. 


Actually, I have just managed to boot from a Windows 7 installed on a new .VHD, and I installed it right from the Windows 7 DVD. We can do a similar process with “Windows Server 2008 R2 (beta)” installed on a .VHD file, as well.


If you’d use Virtual PC 2007 to install the Virtual image, the produced .VHD wouldn’t work when trying to boot from the .VHD. 


A.-  Creating the .VHD file and Windows 7 installation on that .VHD file


UPDATED: When using Windows 7 RC1 “plain vanilla” installed, it usually creates a small initial partition (about 100Mb), and then, when you do the following steps, you have to specify d: drive instead c: drive. If you try with c: and you get an error message sying something like “You don’t have space enough”, try specifying d: drive. 


1. Boot the machine using the Windows 7 DVD
2. Choose Windows Repair
3. start CMD
4. Run Diskpart
5. Type: Create vdisk file=c:\Windows7.vhd maximum=40000 type=expandable
6. Type: select vdisk file=c:\Windows7.vhd
7. Type: attach vdisk (in previous Betas, it was ‘surface’ instead of ‘attach’)
8. Type: ‘exit’ (you exit Windows Repair, but
 Do Not Reboot)
9. Install Windows 7 to this attached .VHD (From Win7 installation, you now have to ‘see’ another Hard Drive, you’ll need to create a partition & format it, first. You might get an error/warning saying that your computer hardware might not support this disk, just ignore it..).
10. Reboot, and you got it!!!!



B.- Configure boot options


You might want to chenge dual boot options, options string name, etc.  


When you want to configure the boot options of windows you can use bcdedit.exe or EasyBCD to modify the boot settings.


Be careful if you use EasyBCD, as current version might not have new Windows 7 options, yet…


So, bcdedit.exe is harder to use, as it is a console app, but it will work ok for sure! 🙂


For instance, once you have booted in Windows 7 (any boot, you might have 2 ‘Windows 7’ option strings… ;-)), you might want to change those boot options strings. In order to do so, start a CMD prompt and run bcdedit.exe (in \Windows\System32) to see the GUID of your boot options:


bcdedit /v


Remember/copy the GUID of your VHD installation and type the following line, of course, changing my ‘xxxxxxxx’ stuff to your GUID.


bcdedit /set {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} description “Windows 7 .VHD Image”


You can put the description you like, but the above line will change the description for your VHD installation boot option.


You can also change the order of the boot options typing the following:


bcdedit /displayorder {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} /addlast



Finally, once you have these kind of .VHD images, you can copy it and have as many BOOT options as you want.


The easiest way is to copy an originall boot menu option, like:


bcdedit /copy {Original_GUID_Number} /d “my new description”
or
bcdedit /copy {current} /d “my new description”
or
bcdedit /copy {default} /d “my new description”


Type again the following to see the new GUID for your new copied boot option:


bcdedit /v


Copy that GUID to a notepad or a paper… 


After that, you must change the 2 pointers within the menu option, so they point to the new/right .VHD file:


bcdedit /set {My_new_GUID_Number} device vhd=[C:]\MyNewVpcFile.vhd 


bcdedit /set {My_new_GUID_Number} osdevice vhd=[C:]\MyNewVpcFile.vhd



So! ,this kind of natively booting is great when you have many Virtual PC images and you want to run it the fastest possible way, I mean, almost like a native installation (We might have a slight delay because everything is stored within a single file, but, it must be a very small difference). In any case, we’re not running a virtual environment nor 2 operating systems at the same time, it must be much faster than using Virtual PC or VMware. ðŸ™‚


Btw, if you need more detailed info because you don’t really know Windows 7 setup, neither bcdedit.exe, check the following post. It is a STEP BY STEP procedure with pictures, etc.:


http://www.sevenforums.com/tutorials/2953-virtual-hard-drive-vhd-file-create-start-boot.html


 

Comments (13)

  1. Yanze says:

    Does this also work when the .vhd file is on an external USB-disk? If so, which path should I use? I tried it last weekend, but it didn’t work, maybe I should try it on an internal disk first.

  2. oco says:

    It seems that diskpart do not like vhd file names starting with "windows" if there is already an existing system on the disk, in a windows directory.

  3. Zunanji viri says:

    Development Change Color of Status Bar of SSMS Query Editor Double-clicking a VS2005 Solution in Vista

  4. Check out here – nothing to add, just that it is a cool blog posting from my architect peer in Spain;)

  5. serega says:

    Is there any way to restore the boot manager back to vista or xp?

  6. sphillips says:

    I also ran into issues using a USB key to do the VHD install. I finally had to use the original DVD that I made the USB key from to install to a VHD.

  7. Helge Klein says:

    The method presented to bring up a command prompt does not work when trying to install the x64 version of Windows 7 on a partition that contains a 32-bit installation of Vista because in that case the setup program will not allow to repair the installation.

    Check out my article on how to work around this:

    http://blogs.sepago.de/helge/2009/03/23/eating-microsofts-dog-food-a-self-experiment-with-windows-7-part-2-installation/

  8. satorukoshiba says:

    I confirmed that it went well to native boot Win7.vhd on my Vista note pc.

    Thank you for sharing knowledge 😀

  9. I’m loving the new Windows version, I’ve been using it on my work and my demo computers since the release

  10. Actualités says:

    I’m loving the new Windows version, I’ve been using it on my work and my demo computers since the release

  11. BGrader says:

    I am still confused 🙁

    Why do we need to create a VHD of Windows7 when you already have windows 7 installed?

    I guess what I am trying to do is achieve dual boot on a single harddrive I have with W2k8 R2 and Win 7 and I have the following questions:

    1. Can I have both as a VHDs which gives me an option at boot time which one I want to install? If yes then how do I acheive that? All I have is the iso for both OS.

    2. Is there any performance hit if both of the OS boots from the VHD? If yes, then which OS should I keep as native boot? Any preference if any?

  12. cesardl says:

    It is nice to have several Windows 7 to boot from especially when you work with BETAS, as I do usually.

    New BETA –> New .VHD starting from a Base Windows 7 .VHD already installed.

  13. CRM says:

    Very interesting post………..

    http://kundedata.dk/