Skip navigation
Build a Bootable BCD from Scratch with Bcdedit

Build a Bootable BCD from Scratch with Bcdedit

Manipulate the Boot Configuration Data file

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:

bcdedit /set {default} device partition=d:
bcdedit /set {default} path \windows\system32\boot\winload.exe
bcdedit /set {default} osdevice partition=d:
bcdedit /set {default} systemroot \Windows
bcdedit /set {default} detecthal yes

Finally, add this command, or Windows won’t see the OS entry properly:

bcdedit /displayorder {default} /addlast

Give this a try with a test machine or two, and you’ll be Doctor Boot in no time!

Learn more from "Bcdedit Basics."

Hide comments

Comments

  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
Publish