Clicky

BCDEDIT Commands to Add VHD / RAMDISK / Legecy OS

BCDEDIT Commands to Add VHD / RAMDISK / Legecy OS

This article will explain the basics of boot configuration editor tool which comes with Windows Vista and above.

BCD stands for Boot Configuration Data. Basically its replacement of traditional  Boot.ini text file.

The Boot process has been changed in windows vista and above. Now the Boot loader (bootmgr) does not longer looks for boot.ini text file instead refer the binary store “bcd” from \boot directory of active partition.

BCD is a binary file which holds the information about boot configuration like number os OS ,Various boot parameters etc. We cannot edit the configuration file BCD with a text editor instead we have to use the inbuilt command line utility BCDEDIT.exe.

The Bcdedit.exe command-line tool modifies the boot configuration data store. The boot configuration data store contains boot configuration parameters and controls how the operating system is booted. These parameters were previously in the Boot.ini file (in BIOS-based operating systems) or in the nonvolatile RAM entries (in Extensible Firmware Interface-based operating systems). You can use Bcdedit.exe to add, delete, edit, and append entries in the boot configuration data store. (description of bcdedit.exe by Microsoft)

If you enter BCDedit /? On a command prompt you will see available options.

So, if you can see all the options and description just by entering bcdedit /? then what’s the mean of writing this article ?

Well, this article explains the basics of Bcdedit and subsequent articles will explains the different uses of using this CLI to make changes.

There are three main elements in the boot configuration: Store – Entries – Entry options.

Store

A BCD store is the binary file which most often resides under \boot directory of the active partition. It can be created , impored or exported. By default all commands operates on the default store located at \boot directory until manually specifed . You can manually specify the store path by providing /store parameter.

Bcdedit.exe /store D:\temp\bcd

Commands that operate on a store
================================
/createstore – Creates a new and empty boot configuration data store.
/export – Exports the contents of the system store to a file. This file  can be used later to restore the state of the system store.
/import – Restores the state of the system store using a backup file  created with the /export command.

Entries

Inside the store there are OS entries. Entries are the one we see at boot selection menu on startup like Windows 7 / windows XP / ETC. Each entry usually have a GUID. Specify the GUID when dealing with entries, By default the commands operates on default entry.

Commands that operate on entries in a store
===========================================
/copy – Makes copies of entries in the store.
/create – Creates new entries in the store.
/delete – Deletes entries from the store.
/mirror – Creates mirror of entries in the store.

bcdedit /create /d "Name of the Entry" /application bootsector

The result will look like this:

The entry {05d33150-3fde-11dc-a457-00021cf82fb0} was successfully created.

Entry options

The most important part of configuration is entry options. It controls the startup like from where to look for the OS loader,the OS partition stuffs.

Commands that operate on entry options
======================================
/deletevalue – Deletes entry options from the store.
/set – Sets entry option values in the store.

Lets take an example how can we manually add windows XP to Windows 7 boot loader.

ADD Legecy OS loader

Below commands will add a legecy OS loader like ntldr or some kind of linux boot loaders.

bcdedit /create /d "Name of the Entry" /application bootsector

The result will look like this:

The entry {05d33150-3fde-11dc-a457-00021cf82fb0} was successfully created.

The long string {05d33150-3fde-11dc-a457-00021cf82fb0} is the id for this entry. Then, use the following commands to set boot parameters: replace {id} with the actual id returned from the previous command.

bcdedit /set {67bc6121-f766-11df-b1a0-00247eea28eb} device boot
bcdedit /set {67bc6121-f766-11df-b1a0-00247eea28eb} path \ntldr
bcdedit /displayorder {{67bc6121-f766-11df-b1a0-00247eea28eb} /addlast

It will add an entry of the given name in boot loader,When you select it, the control will passed to ntldr or any other boot loader you specify (replace ntldr in 2nd command with the filename of alternative boot loader)