Fix and Customize Boot for Windows

In Windows Recovery Environment, there are couple tools that do the job.
If just want to fix the boot problem, BootRec.exe maybe is the easiest way.
if just want fix BCD, try Bcdboot.exe, it has less steps. But, BcdEdit.exe has more options to customize DCD.
BootSect.exe is a tool to fix boot sector for MBR disk. It wont work for GPT disk.
BootCfg.exe is a tool to configure for boot.ini.

BootRec – Boot Recovery tool

Repairs critical disk structures. The following commands are supported:
/FixMbr - writes the master boot record of the system partition using the master boot record compatible with Windows. This operation does not overwrite the existing partition table.
/FixBoot - write a new boot sector onto the system partition using the boot sector compatible with Windows.
/ScanOs - scan all disks for installations compatible with Windows and display the entries that are currently not in the boot configuration store.
/RebuildBcd - scan all disks for installations compatible with Windows and allow the user to choose which to add to the boot configuration store.

Bcdboot – Bcd boot file creation and repair tool.

The bcdboot.exe command-line tool is used to copy critical boot files to the system partition and to create a new system BCD store.

bcdboot [/l ] [/s [/f ]] [/v] [/m [{OS Loader ID}]] [/addlast]

source Specifies the location of the windows system root.

/l - Specifies an optional locale parameter to use when initializing the BCD store. The default is US English.
/s - Specifies an optional volume letter parameter to designate the target system partition where boot environment files are copied. The default is the system partition identified by
the firmware.
/v - Enables verbose mode.
/m - If an OS loader GUID is provided, this option merges the given loader object with the system template to produce a bootable entry. Otherwise, only global objects are merged.
/d - Specifies that the existing default windows boot entry should be preserved.
/f - Used with the /s command, specifies the firmware type of the target system partition. Options for are 'UEFI', 'BIOS', or 'ALL'.
/addlast - Specifies that the windows boot manager firmware entry should be added last. The default behavior is to add it first.

Examples: bcdboot c:\windows /l en-us
bcdboot c:\windows /s h:
bcdboot c:\windows /s h: /f UEFI
bcdboot c:\windows /m {d58d10c6-df53-11dc-878f-00064f4f4e08}
bcdboot c:\windows /d /addlast

BCDEDIT – Boot Configuration Data Store Editor


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.

For detailed command and option information, type bcdedit.exe /? . For example, to display detailed information about the /createstore command, type:

bcdedit.exe /? /createstore

For an alphabetical list of topics in this help file, run "bcdedit /? TOPICS".

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.
/sysstore - Sets the system store device (only affects EFI systems, does not persist across reboots, and is only used in cases where the system store device is ambiguous).

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.

Run bcdedit /? ID for information about identifiers used by these commands.

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

Run bcdedit /? TYPES for a list of datatypes used by these commands.
Run bcdedit /? FORMATS for a list of valid data formats.

Commands that control output
============================
/enum - Lists entries in the store.
/v - Command-line option that displays entry identifiers in full, rather than using names for well-known identifiers. Use /v by itself as a command to display entry identifiers in full for the ACTIVE type.

Running "bcdedit" by itself is equivalent to running "bcdedit /enum ACTIVE".

Commands that control the boot manager
======================================
/bootsequence - Sets the one-time boot sequence for the boot manager.
/default - Sets the default entry that the boot manager will use.
/displayorder - Sets the order in which the boot manager displays the multiboot menu.
/timeout - Sets the boot manager time-out value.
/toolsdisplayorder - Sets the order in which the boot manager displays the tools menu.

Commands that control Emergency Management Services for a boot application
==========================================================================
/bootems - Enables or disables Emergency Management Services for a boot application.
/ems - Enables or disables Emergency Management Services for an operating system entry.
/emssettings - Sets the global Emergency Management Services parameters.

Command that control debugging
==============================
/bootdebug - Enables or disables boot debugging for a boot application.
/dbgsettings - Sets the global debugger parameters.
/debug - Enables or disables kernel debugging for an operating system entry.
/hypervisorsettings - Sets the hypervisor parameters.

bootsect – Boot sector restoration tool

bootsect {/help|/nt60|/nt52} {SYS|ALL|:} [/force] [/mbr]

Bootsect.exe updates the master boot code for hard disk partitions in order to switch between BOOTMGR and NTLDR. You can use this tool to restore the boot sector on your computer.

/help - Displays these usage instructions.
/nt52 - Applies the master boot code that is compatible with NTLDR to SYS, ALL, or . The operating system installed on SYS, ALL, or must be older than Windows Vista.
/nt60 - Applies the master boot code that is compatible with BOOTMGR to SYS, ALL, or . The operating system installed on SYS, ALL, or must be Windows Vista, Windows Server 2008 or later.
SYS - Updates the master boot code on the system partition used to boot Windows.
ALL - Updates the master boot code on all partitions. ALL does not necessarily update the boot code for each volume. Instead, this option updates the boot code on volumes that could be used as Windows boot volumes, which excludes any dynamic volumes that are not connected with an underlying disk partition. This restriction is present because boot code must be located at the beginning of a disk partition.
DriveLetter: - Updates the master boot code on the volume associated with this drive letter. Boot code will not be updated if either 1) is not associated with a volume or 2) is associated with a volume not connected to an underlying disk partition.
/force - Forcibly dismounts the volume(s) during the boot code update. You should use this option with caution.
If Bootsect.exe cannot gain exclusive volume access then the file system may overwrite the boot code before the next reboot. Bootsect.exe always attempts to lock and dismount the volume before each update. When /force is specified, a forced dismount is attempted if the initial lock attempt fails. A lock can fail, for example, if files on the target volume are currently opened by other programs.
When successful, a forced dismount allows exclusive volume access and a reliable boot code update even though the initial lock failed. At the same time, a forced dismount invalidates all open handles to files on the target volume. This could result in unexpected behavior from the programs that opened these files. Therefore, you should use this option with caution.
/mbr - Updates the Master Boot Record without changing the partition table on sector 0 of the disk that contains the partition specified by SYS, ALL, or drive letter. When used with /nt52 option, the master boot record is compatible with operating systems older than Windows Vista. When used with the /nt60 option, the master boot record is compatible with Windows Vista, Windows Server 2008 or later.

Example:
To apply the master boot code that is compatible with NTLDR to the volume labeled E:, use the following command:
bootsect /nt52 E:

BootCFG
BootCFG is a configuration tool for boot.ini

Advertisements
This entry was posted in Windows. Bookmark the permalink.

2 Responses to Fix and Customize Boot for Windows

  1. Ori Shiran says:

    thank you so much for this, was able to build an entire rec pt for destoryed r2 srv using this as re

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s