Manually updating / creating BCD files for Windows 7/8 using bcdedit

By | September 16, 2013
Share

Compliments of an excellent write-up: http://diddy.boot-land.net/bcdedit/files/examples1.htm

 

Examples – Part 1


The BCD Store used to boot the operating system may be in use as the system store – if a system store is in use then this will be the default store on which all bcdedit commands are carried out. If no system store is in use, or to specify a store other than the system store, the /store switch must be used.

I personally recommend using the /store switch whenever modifying a BCD store to reduce the risk of targeting the wrong store. To specify the BCD store D:\Boot\BCD we would use the commandbcdedit.exe /store D:\Boot\BCD …..

Before modifying a BCD store I recommend that you create a backup. Be aware that modifying a BCD store could result in your system not booting, I therefore recommend that you take either of the following precautions –

  • Create a BOOTMGR bootable CD/DVD/USB/Floppy with your existing (working) BCD store copied to it. BCD entries (with the exception of any devices set as BOOT) contain disk signature and partition offset information – booting the BCD store from another device will therefore still target the correct device.
  • Create a WinPE bootable CD/DVD/USB disk and use this to replace a non-working BCD store with the backup you made earlier. If you do not have access to WinPE then many Linux Live distributions can also be used.

All examples in this section use the same format – the commands as they would be entered at a command prompt followed by an example batch file automating these commands. All of these examples use the /store switch to specify BCD store C:\Boot\BCD. Don’t forget to change the device/path when adapting these examples to your own system.

 

Create a new (empty) store

  • bcdedit.exe /createstore C:\Boot\BCD

 

Create {bootmgr} entry

  • bcdedit.exe /store C:\Boot\BCD /create {bootmgr}
  • bcdedit.exe /store C:\Boot\BCD /set {bootmgr} description “Boot Manager”
  • bcdedit.exe /store C:\Boot\BCD /set {bootmgr} device boot
  • bcdedit.exe /store C:\Boot\BCD /set {bootmgr} timeout 20

 

Create entry for Windows Vista/7

The following entry will add a menu option for either Windows Vista or 7 – don’t forget to change thedescription entry.

  • bcdedit.exe /store C:\Boot\BCD /create /application osloader

Running this first command will return a Globally Unique IDentifier (GUID) value – e.g. {e05b4c23-618a-11df-89c6-001d925a73cf}. In all subsequent commands replace {guid} with this value –

  • bcdedit.exe /store C:\Boot\BCD /set {guid} device partition=C:
  • bcdedit.exe /store C:\Boot\BCD /set {guid} path \Windows\system32\winload.exe
  • bcdedit.exe /store C:\Boot\BCD /set {guid} osdevice partition=C:
  • bcdedit.exe /store C:\Boot\BCD /set {guid} systemroot \Windows
  • bcdedit.exe /store C:\Boot\BCD /set {guid} description “Windows 7”
  • bcdedit.exe /store C:\Boot\BCD /displayorder {guid} /addlast

These commands will boot Windows Vista/7 but will not add any advanced options such asresumeobject‘s or F8 Windows Recovery Environment.

 

Create {ntldr} entry

The {ntldr} option can be used to boot legacy operating systems including Windows 2000/XP/2003. This option is generally only used in dual or multiboot systems. The files boot.ini and ntdetect.com(from an existing Windows 2000/XP/2003) will need to be copied to the boot partition containing BOOTMGR and the BCD store.

Don’t forget to change the device partition= to the drive containing your own Windows 2000/XP/2003 installation. Also change the description as required.

  • bcdedit.exe /store C:\Boot\BCD /create {ntldr}
  • bcdedit.exe /store C:\Boot\BCD /set {ntldr} device partition=C:
  • bcdedit.exe /store C:\Boot\BCD /set {ntldr} path \ntldr
  • bcdedit.exe /store C:\Boot\BCD /set {ntldr} description “Windows XP”
  • bcdedit.exe /store C:\Boot\BCD /displayorder {ntldr} /addlast

 

Create entry for VHD boot

At this time only Windows 7 (Ultimate and Enterprise) and Windows Server 2008 R2 can be booted from a VHD file. These commands will add an entry for an existing VHD installation. Edit thedescription and device path as required.

  • bcdedit.exe /store C:\Boot\BCD /create /application osloader

Running this first command will return a Globally Unique IDentifier (GUID) value – e.g. {e05b4c23-618a-11df-89c6-001d925a73cf}. In all subsequent commands replace {guid} with this value –

  • bcdedit.exe /store C:\Boot\BCD /set {guid} device vhd=[C:]\vhd\seven.vhd
  • bcdedit.exe /store C:\Boot\BCD /set {guid} path \Windows\system32\winload.exe
  • bcdedit.exe /store C:\Boot\BCD /set {guid} osdevice vhd=[C:]\vhd\seven.vhd
  • bcdedit.exe /store C:\Boot\BCD /set {guid} systemroot \Windows
  • bcdedit.exe /store C:\Boot\BCD /set {guid} description “Windows 7 VHD”
  • bcdedit.exe /store C:\Boot\BCD /displayorder {guid} /addlast

 

Create entry for Grub4dos

The following example uses device boot – this can be changed to device partition=#:. You will need to copy grldr.mbr to the device specified. You will then need to copy grldr and menu.lst to any supported partition (FAT/NTFS/EXT2/3).

  • bcdedit.exe /store C:\Boot\BCD /create /application bootsector

Running this first command will return a Globally Unique IDentifier (GUID) value – e.g. {e05b4c23-618a-11df-89c6-001d925a73cf}. In all subsequent commands replace {guid} with this value –

  • bcdedit.exe /store C:\Boot\BCD /set {guid} device boot
  • bcdedit.exe /store C:\Boot\BCD /set {guid} path \grldr.mbr
  • bcdedit.exe /store C:\Boot\BCD /set {guid} description “Grub4dos”
  • bcdedit.exe /store C:\Boot\BCD /displayorder {guid} /addlast

 

Create {ramdiskoptions} entry

As far as I am aware {ramdiskoptions} is only used in order to boot a Windows Vista/2008/7 based WinPE. {ramdiskoptions} is used to identify the .sdi file required during the initial stages of booting WinPE.

Due to a bug any subsequent WinPE based objects do not display their own descriptions if a {ramdiskoptions} description has been set. Do not therefore specify any description for {ramdiskoptions} – thanks to boot-land forum member cdob for this tip (see here).

The following example uses device boot – this can be changed to device partition=#: if required. Edit the ramdisksdipath path as required.

  • bcdedit.exe /store C:\Boot\BCD /create {ramdiskoptions}
  • bcdedit.exe /store C:\Boot\BCD /set {ramdiskoptions} ramdisksdidevice boot
  • bcdedit.exe /store C:\Boot\BCD /set {ramdiskoptions} ramdisksdipath \Boot\boot.sdi

Create entry for WinPE

A {ramdiskoptions} object must exist before creating an entry for WinPE. The following example usesdevice ramdisk=[boot] – this can be changed to device ramdisk=[#:] if required. Edit thedescription and device path as required.

 

  • bcdedit.exe /store C:\Boot\BCD /create /application osloader

Running this first command will return a Globally Unique IDentifier (GUID) value – e.g. {e05b4c23-618a-11df-89c6-001d925a73cf}. In all subsequent commands replace {guid} with this value –

  • bcdedit.exe /store C:\Boot\BCD /set {guid} systemroot \Windows
  • bcdedit.exe /store C:\Boot\BCD /set {guid} detecthal Yes
  • bcdedit.exe /store C:\Boot\BCD /set {guid} winpe Yes
  • bcdedit.exe /store C:\Boot\BCD /set {guid} osdevice ramdisk=[boot]\Boot\boot.wim,{ramdiskoptions}
  • bcdedit.exe /store C:\Boot\BCD /set {guid} device ramdisk=[boot]\Boot\boot.wim,{ramdiskoptions}
  • bcdedit.exe /store C:\Boot\BCD /set {guid} description “Windows PE”
  • bcdedit.exe /store C:\Boot\BCD /displayorder {guid} /addlast

 

Using multiple {ramdiskoptions}

Thanks to boot-land forum member cdob for this tip (see here).

Although only one {ramdiskoptions} object can be created it is possible to use a different .sdi file to the one specifed in {ramdiskoptions} ramdisksdipath by using the following workaround. At present I have not found any real use for implementing this however, as cdob points out, it may be necessary in future.

  1. bcdedit.exe /store C:\Boot\BCD /create /device

Running this first command will return a Globally Unique IDentifier (GUID) value – e.g. {e05b4c23-618a-11df-89c6-001d925a73cf}. In all subsequent commands replace {ramdisk_guid} with this value –

  1. bcdedit.exe /store C:\Boot\BCD /set {ramdisk_guid} ramdisksdidevice partition=C:
  2. bcdedit.exe /store C:\Boot\BCD /set {ramdisk_guid} ramdisksdipath \Boot\different.sdi

Now to use this to boot WinPE –

  1. bcdedit.exe /store C:\Boot\BCD /create /application osloader

Running this command will return a Globally Unique IDentifier (GUID) value – e.g. {bdaf610c-622d-11df-a7ee-a711d7fae90e}. In all subsequent commands replace {guid} with this value and replace {ramdisk_guid} with the GUID created by running the command in step 1 –

  1. bcdedit.exe /store C:\Boot\BCD /set {guid} systemroot \Windows
  2. bcdedit.exe /store C:\Boot\BCD /set {guid} detecthal Yes
  3. bcdedit.exe /store C:\Boot\BCD /set {guid} winpe Yes
  4. bcdedit.exe /store C:\Boot\BCD /set {guid} osdevice ramdisk=[C:]\Sources\boot.wim,{ramdisk_guid}
  5. bcdedit.exe /store C:\Boot\BCD /set {guid} device ramdisk=[C:]\Sources\boot.wim,{ramdisk_guid}
  6. bcdedit.exe /store C:\Boot\BCD /set {guid} description “Windows PE”
  7. bcdedit.exe /store C:\Boot\BCD /displayorder {guid} /addlast

Leave a Reply

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

*