Build a Bootable BCD from Scratch with Bcdedit

In "Fix Unbootable Systems with Bootsect" (June 2011), I talked about how to fix a Windows 7/R2 system that can’t boot, and I bolstered that discussion with an explanation of the Windows 7/R2 boot record and the Bootmgr application. Once Bootmgr starts up, though, it needs some marching orders, and it gets those from a binary file called the Boot Configuration Data (BCD) file , which usually lives in a folder named \boot on the active partition. You use Bcdedit to configure the BCD file. You've already read about Bcdedit in my explanations of how to create or modify “OS entries” (instructions for how to boot OSs on the system’s hard drives), but all I’ve really explained so far is how to use Bcdedit to modify an existing BCD. This month, I'll show you how to build a bootable BCD from scratch.

A working BCD file typically contains at least two objects. First, it has a Boot Manager, which contains overall boot information such as which OS entry to boot by default and the amount of seconds to wait for the user if more than one OS entry exists. Second, it contains at least one OS entry. Here’s how to create them.

Start by deleting any existing BCD files and creating a new empty BCD file. Bcdedit quirkily requires you to first create a new BCD file somewhere and then “import” it—a process that copies whatever is in the new BCD file into the “official” BCD file in \boot on the active volume. You can do that by typing two commands into an elevated command prompt:

bcdedit /createstore bcd bcdedit /import bcd

These commands work whether you already have a \boot\bcd in place or if you’re working from a toasted boot volume that lacks any BCD file at all. Now that you’ve done that, the “sacrificial" BCD file is no longer necessary, so you can delete it:

del bcd

Next, create the Boot Manager piece of the BCD file by typing

bcdedit /create {bootmgr}

Note the /create option in this command instead of the /createstore option in the earlier command. You’ll use the former quite often in BCD work and the latter much less so. The /create option lets Bcdedit create several different kinds of BCD objects. Invoking it with the {bootmgr} identifier creates that overall Boot Manager section. (Note that I haven't included a description with the /d option, despite the fact that every example I can find on the Web does. It’s superfluous when creating a Boot Manager object.)

The Boot Manager doesn’t need much tweaking, but it does need to know what volume to boot from and how many seconds to wait for a user to choose an OS option. These options will work fine:

bcdedit /set {bootmgr} device boot bcdedit /timeout 30

Next, create the OS entry object that will tell the Boot Manager to boot Windows from files in the \Windows folder on one of the system’s volumes. That volume is usually C, but if you’re booted from Windows Preinstallation Environment (WinPE), double-check which drive has the \Windows folder on it—WinPE might see it as D or E. (That’ll be important in a minute.)

Now, create the OS entry object:

bcdedit /create /d "Windows 7" /application osloader

The /create option (without an ID) and the /application osloader option tell Windows that you’re creating an OS entry for a Vista-and-later version of Windows. (The /d option contains the label that Boot Manager shows when offering multiple OS entries.) That returns a new GUID that you should plug into this next command:

bcdedit /default {<GUID>}

At this point, you’ve got a naked object that needs some values with the Bcdedit /set command that I introduced in earlier Bcdedit columns, but what to set those values to? Simple! Look at the output of Bcdedit on a healthy copy of Windows, and use it as a model. In my case, the \Windows folder is on drive D, so I entered these:

Discuss this Article 5

"The 100 MB System Reserved partition is used for the Boot Manager code, BCD (Boot Configuration Database), System Recovery Options (Windows RE), and start up files for BitLocker (if turned on).
If you want to have the 100 MB System Reserved partition in addition to the Windows 7 C: partition on a HDD or SSD after installation, then you would need to make sure that all partitions on the drive have been deleted until it is only unallocated space. Next, select the unallocated drive to install Windows 7 on. If there are no partitions on the disk, you will get the 100 MB System Reserved.
If you do not want to have the 100 MB System Reserved partition and only the Windows 7 C: partition on a HDD or SSD after installation, then select a formatted partition or drive to install Windows 7 on. If there are any partitions on the disk, you won't get the 100 MB System Reserved."

so, if you install windows to an EMPTY drive (unallocated space), a system partition (100 Mb) will be created, containing BCD info.... is this a precaution, a precursor to windows 7's "bcd in boot" configuration (illustrated above), or the non-virtualized way of doing things?

I'm still trying to go native vhd on barebones, having suffered a boot failure with my win7 vhd.... trying to understand what to do following the 'clean disk' operation

Originally scott's guide seemed logical, but having suffered boot issues, I want to protect myself from a repeat, and ideal avoid an windows/software reinstall (this is the land of V-OS after all!!)!
http://www.hanselman.com/blog/LessVirtualMoreMachineWindows7AndTheMagicOfBootToVHD.aspx

These instructions are gold. There are probably 500 questions on Microsoft's support site that have gone unanswered dealing with this very subject. I think you may be the only person in the world with this knowledge.

You are my king.
After going through hundred of web site and Microsoft support articles and forum, after testing everything I could, I tested your instructions with serious doubt. It worked! I had a "File: \Boot\BCD, Status: 0xc000000f An error occured while attempting to read the boot configuration data" and now, thanks to YOU! its just booting properly. Thank you so much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

A good friend has done "something" to his Win 8.1 & it's on an M.2 drive. Right now, all I see in Diskpart is that the partition exists, but a live Linux usb doesn't see what should be there. I tried the above in bcdedit & all completed successfully but still no boot. Is the above only for 7, & if so, can you please list what would be required for 8.1? Also, this laptop will NOT boot to a CD. Thank you.

Azure Master Class

Every organization is currently evaluating how they can utilize the public cloud, what it means, and how to actually get started. This 12 session Master Class will equip you with everything you need to understand, evaluate, deploy and maintain environments that utilize Microsoft Azure including hybrid scenarios.