Difference between revisions of "Master Boot Record"

From ArchWiki
Jump to: navigation, search
(Resources: - Added section on restoring a Windows Boot Record)
m (Russian Language added)
Line 2: Line 2:
[[Category:Mainboards and BIOS (English)]]
[[Category:Mainboards and BIOS (English)]]
[[Category:System recovery (English)]]
[[Category:System recovery (English)]]
{{Article summary start}}
{{Article summary start}}
{{Article summary text|An overview of the Master Boot Record; the first sector of a partitioned data storage device.}}
{{Article summary text|An overview of the Master Boot Record; the first sector of a partitioned data storage device.}}
{{Article summary heading|Available in languages}}
{{Article summary heading|Available in languages}}
{{i18n entry|English|Master Boot Record}}
{{i18n|Master Boot Record}}
{{Article summary heading|Related articles}}
{{Article summary heading|Related articles}}
{{Article summary wiki|GRUB}}
{{Article summary wiki|GRUB}}

Revision as of 21:03, 27 February 2010

Template:Article summary start Template:Article summary text Template:Article summary heading

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

Template:Article summary heading Template:Article summary wiki Template:Article summary wiki Template:Article summary wiki Template:Article summary end

The Master Boot Record (MBR) is the first sector (first 512 bytes) of a storage device. The MBR is not a partition and it is reserved for the operating systems bootloader and the storage device's partition table.

Boot Process

Booting is a multi-stage process. Most PCs today initialize system devices by firmware called the BIOS (Basic Input/Output System). The BIOS is typically contained within the CMOS (Ceramic Metal Oxide Semiconductor) that is executed upon system power-up. After system devices have been initialized, the BIOS then looks for the bootloader on the MBR of the first recognized storage device (hard disk drive, solid state drive, CD/DVD drive, USB drive...) or the first partition of the device. It then exectutes that program. The bootloader reads the partition table and is then capable of loading the operating system(s). Common GNU/Linux bootloaders include GRUB and LILO.


The MBR consists of a short piece of assembly code (the initial bootloader – 446 bytes), a partition table for the 4 primary partitions (16 bytes each) and a sentinel (0xAA55).

The "Conventional" Windows/DOS MBR bootloader code will check the partition table for one and only one active partition, read X sectors from this partition and then transfer control to the operating system. The Windows/DOS bootloader can not boot an Arch Linux partition because it is not designed to load the Linux kernel, and it can only cater for an active, primary partition (which GRUB safely ignores).

The GRand Unified Bootloader (GRUB) is the de facto standard bootloader for GNU/Linux, and users are recommended to install it on the MBR to allow booting from any partition, whether it be primary or logical.

Backup and restoration

Because the MBR is located on the disk it can be backed up and later recovered.

To backup the MBR:

dd if=/dev/hda of=/path/mbr-backup bs=512 count=1

Restore the MBR:

dd if=/path/mbr-backup of=/dev/hda bs=512 count=1
Warning: Restoring the MBR with a mismatching partition table will make your data unreadable and nearly impossible to recover. If you simply need to reinstall the bootloader see GRUB or LILO.

To erase the MBR (may be useful if you have to do a full reinstall of another operating system):

dd if=/dev/zero of=/dev/hda bs=446 count=1

Restoring a Windows Boot Record

Windows by convention (and for ease of installation) is usually installed on the first partition and hence installs it's bootloader and partition table on the first sector of that partition. If you accidentally install a bootloader like GRUB to the Windows partition or some other way damage the boot record, you will have to use a utility to reinstall it. Windows includes an MBR fix in their Recovery CD's or sometimes the install CD called Template:Codeline. Using this method will repair the MBR (i.e. reinstall the Windows bootloader and add again the partition table. After doing this you will have to reinstall GRUB. By doing this the GRUB bootloader can then start the Windows bootloader when called. If by chance you do not have a Windows Install/Recover CD, then you can reinstall it again in Linux with a utility called Template:Package AUR. First you will need to boot from a LiveCD and then call Template:Package AUR. Most LiveCD's don't have this utility by default so it will need to be installed first, or you can look at a Rescue CD that does have it like Parted Magic.

First, write the partition info (table) again by:

ms-sys --partition /dev/sda1

Then write to write a Windows 2000/XP/2003 MBR:

ms-sys --mbr /dev/sda

Template:Package AUR can also write Windows 98, ME, Vista, and 7 MBRs as well, see Template:Codeline.