Master Boot Record - Editing/replacing MBR Contents

Editing/replacing MBR Contents

Though it is possible to manipulate the bytes in the MBR sector directly using various disk editors, there are tools to write fixed sets of functioning code to the MBR. Since MS-DOS 5.0, the program FDISK has included the switch /MBR, which will rewrite the MBR code. Under Windows 2000 and Windows XP, the Recovery Console can be used to write new MBR code to a storage device using its fixmbr command. Under Windows Vista and Windows 7, the Recovery Environment can be used to write new MBR code using the BOOTREC /FIXMBR command. Some third-party utilities may also be used for directly editing the contents of partition tables (without requiring any knowledge of hexadecimal or disk/sector editors), such as MBRWizard.

dd is also a commonly used POSIX command to read or write to any location on a storage device, MBR included. In Linux, ms-sys may be used to install a Windows MBR. The GRUB and LILO projects have tools for writing code to the MBR sector, namely grub-install and lilo -mbr. The GRUB Legacy interactive console can write to the MBR, using the setup and embed commands, but GRUB2 currently requires grub-install to be run from within an operating system.

Various programs are able to create a "backup" of both the primary partition table and the logical partitions in the extended partition.

Linux sfdisk (on a SystemRescueCD) is able to save a backup of the primary and extended partition table. It creates a file that can be read in a text editor, or this file can be used by sfdisk to restore the primary/extended partition table. An example command to back up the partition table is sfdisk -d /dev/hda > hda.out and to restore is sfdisk /dev/hda < hda.out. It is possible to copy the partition table from one disk to another this way, useful for setting up mirroring, but it should be noted that sfdisk executes the command without prompting/warnings using sfdisk -d /dev/sda | sfdisk /dev/sdb.

Read more about this topic:  Master Boot Record

Famous quotes containing the words editing, replacing and/or contents:

    In this century the writer has carried on a conversation with madness. We might almost say of the twentieth-century writer that he aspires to madness. Some have made it, of course, and they hold special places in our regard. To a writer, madness is a final distillation of self, a final editing down. It’s the drowning out of false voices.
    Don Delillo (b. 1926)

    I do not mean to imply that the good old days were perfect. But the institutions and structure—the web—of society needed reform, not demolition. To have cut the institutional and community strands without replacing them with new ones proved to be a form of abuse to one generation and to the next. For so many Americans, the tragedy was not in dreaming that life could be better; the tragedy was that the dreaming ended.
    Richard Louv (20th century)

    Such as boxed
    Their feelings properly, complete to tags
    A box for dark men and a box for Other
    Would often find the contents had been scrambled.
    Gwendolyn Brooks (b. 1917)