Categories
Windows

Boot From VHD – Replacing Vista or Windows 2008 Bootloader with Windows 7 Bootloader

Windows 7 introduce a cool feature enabling us to boot OS on bare metal from a VHD file. This is done by using the new bootloader which comes with Windows 7.

So many people out there (specially techie) who might have vista or windows 2008 as their OS might want to try out Windows 7 or already might have it as a VHD. This could be achieved without having to go through re-partitioning, re-formatting and without loosing old OS. The only thing we need to do is to load Windows 7 bootlaoder replacing the existing Vista or Windows 2008 bootloader. This will not work with Windows 2003 or XP as they use ntldr as boot manager to load OS. With Vista/Win 2008 Microsoft changed the boot manager with bootmgr which is in you system partition. bootmgr does reads its configuration from bcd file. The bcd file can be edited with command line tool bcdedit.exe

You will need following things as we go ahead

– Windows 7 Media for platform you are using i.e. x86/x64 (any version will work)

– A VHD file having Windows 7 already installed. (How to make one?)

Let start the ball rolling

COPYING BOOTLOADER

1. Insert the bootable Windows 7 media into CD-ROM and boot from it

2. Select your language country and then click “Next” on welcome screen

3. On Installation screen click on “Repair your Computer”

image

4. On “System Recovery Options” select “Restore your computer using a system that you created earlier.” and click on “Next”

image

5. On “Re-image Your Computer” click “Cancel” and then again click on “Cancel”

image

6. On “System Recovery Options” click on “Command Prompt”

image

7. Once you get to command prompt we need to know drive letter assigned to you CD-ROM, so type “diskpart” and hit enter

8. Then at DISKPART prompt type “list volume”

image

9. Note drive letter assigned to your CD-ROM (as highlighted in picture as “E”)

10. Find which is you system drive where you can find file “bootmgr”. You can change the command prompt to each drive letter and run command “dir /ah”. In my case as screen shot below the file “bootmgr” is located in “C” drive.

– Now you need to run the following command “attrib –s –h –r c:\bootmgr”

– Execute the following command “xcopy /y /h c:\bootmgr c:\bootmgr.bak”

image

11. On command prompt change the drive to cd-rom in my case it is “E” so type “e:” and enter, make sure the you are root folder of CD if not then run “cd\”

– Execute the following command “xcopy /y /h e:\bootmgr c:\bootmgr”

image

12. Now on command prompt change your drive letter to installation drive which should be “X” so type “X:” and hot enter.

– Change the directory to “cd\windows\system32”

– We need to replace file “bcdedit.exe” for vista with version from Windows 7.

– Find you vista sytem32 directory which in my case is “D:\Windows\Ssytem32”

– backup your original file, execute the following command “xcopy /y /b d:\windows\system32\bcdedit.exe d:\windows\system32\bcdedit.bak” and press “f” at prompt to say xcopy that this is a file

– execute the following command to copy windows 7 version of the file “xcopy /y /b bcdedit.exe d:\windows\system32\bcdedit.exe”

image

 

CREATING BOOTLOADER BCD ENTRY TO BOOT FROM VHD

1. Run command “bcdedit /v”

2. Copy the identifier (GUID) for your current OS into clipboard, in my case it was “{68739be9-9d9a-11de-b17d-f00e6f1861b1}” marked in yellow

3. Execute command “bcdedit /copy {68739be9-9d9a-11de-b17d-f00e6f1861b1} /d “Windows 7””

4. Copy the new GUID to clipboard assigned to the copied entry in my case(marked blue) it was “{68739bec-9d9a-11de-b17d-f00e6f1861b1}”, the only difference was 8th character so do not miss this

5. Execute command “bcdedit /set {68739bec-9d9a-11de-b17d-f00e6f1861b1} device vhd=[d:]\MyVHD\Windows7.vhd”

NOTE: I assume that you already had a vhd file copied to your D: in my case this was the only data partition i had on my system where i had kept this vhd. Make sure that the drive letter is in square bracket.

6. Execute command “bcdedit /set {68739bec-9d9a-11de-b17d-f00e6f1861b1} osdevice vhd=[d:]\MyVHD\Windows7.vhd”

7. Execute command “bcdedit /set {68739bec-9d9a-11de-b17d-f00e6f1861b1} detecthal on”

image

8. Type “exit” on command prompt

9. On “System Recovery Options” click on “Restart”

 

So did this post answer your question?

– Loading Windows 7 Bootloader without loading Windows 7

– How to add a Windows 7 VHD to Vista’s boot manager menu

– Replacing Windows Server 2008 bootloader with Windows 7 bootloader to enable booting from vhd files

– windows 7 creating boot loader partition

– Native Boot to Windows 7 in VHD from Windows Vista

By Sameer Dhoot

Welcome to my blog. I am IT Professional with 10 years of experience across several IT disciplines. I am currently based in Farmington Hills, Michigan, USA. I hope that you find my blog of interest. It is mostly around Microsoft platform including SharePoint, SQL Server, TFS, Windows OS, Virtualization as this is what I am currently working on, but my aim is to write about all of the competencies described in my profile and write contents which I believe can be helpful to broader audience (IT Pros) and may include general computing advice, how-to's, FAQ, Tips and Tricks. I would welcome contributors and critics who would help to build this blog in terms of better contents and usability.

7 replies on “Boot From VHD – Replacing Vista or Windows 2008 Bootloader with Windows 7 Bootloader”

Would you be able to use this method to boot from a VHD on a hard drive without any previous operating system on it?

ie: you have a bare metal system with no OS whatsoever and want to boot from VHD

Conceptually you should be able to boot a VHD on hard disk without any primary OS on it. You essentially need to have a NTFS formatted partition and when you are at command prompt need to run some additional command before loading the bootloader. I have not done this my self but will try to do it over this weekend. Following are the command you would need to run

1. bootsect /nt60 all /force /mbr
2. bootrec.exe /fixmbr
3. bootrec.exe /fixboot
4. bootrec.exe /rebuildbcd

I will test this out and update the post. Meanwhile do try this out and let me know if this worked for you.

Thanks! Good article.
You can skip a couple of steps using Shift + F10 to get a command prompt beginning from “Installation screen” (step 3) 😉

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.