Está en la página 1de 2

Build a Bootable BCD from Scratch with Bcdedit

Manipulate the Boot Configuration Data file


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 systems hard drives), but all Ive 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. Heres 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 ita 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 youre working
from a toasted boot volume that lacks any BCD file at all. Now that youve 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. Youll 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.
Its superfluous when creating a Boot Manager object.)
The Boot Manager doesnt 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 systems volumes. That volume is usually C, but if youre
booted from Windows Preinstallation Environment (WinPE), double-check which drive has
the \Windows folder on itWinPE might see it as D or E. (Thatll 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
youre 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, youve 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
bcdedit
bcdedit
bcdedit
bcdedit

/set
/set
/set
/set
/set

{default}
{default}
{default}
{default}
{default}

device partition=d:
path \windows\system32\boot\winload.exe
osdevice partition=d:
systemroot \Windows
detecthal yes

Finally, add this command, or Windows wont see the OS entry properly:
bcdedit /displayorder {default} /addlast

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

También podría gustarte