Difference between revisions of "Master Boot Record"

From ArchWiki
Jump to: navigation, search
m (cleanup re: installing to MBR or partition)
(More basic introduction, separated details into: 'Boot Process' and 'History')
Line 12: Line 12:
 
{{Article summary end}}
 
{{Article summary end}}
  
Most PCs today use firmware called the [http://en.wikipedia.org/wiki/BIOS BIOS] (Basic Input/Output System).  The BIOS is typically contained within a CMOS (Ceramic Metal Oxide Semiconductor) and executes upon system power-up, proceeding to initialize system devices.  After system devices have been initialized, the BIOS then launches a program on the Master Boot Record (MBR).  The MBR is the first sector (first 512 bytes) of a storage device (hard disk drive, solid state drive, CD/DVD drive, USB drive...).  The BIOS launches the program on the MBR of the first recognized BIOS boot device on your computer.  This program (also known as a bootloader) reads the partition table (also contained within the MBR) and eventually boots the operating system(s).  Common GNU/Linux bootloaders include [[GRUB]] and [[LILO]].
+
The 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.
  
== Booting ==
+
== Boot Process ==
  
''A brief overview of the boot process''[http://bbs.archlinux.org/viewtopic.php?id=86361]
+
Booting is a multi-stage process.  Most PCs today initialize system devices by firmware called the [http://en.wikipedia.org/wiki/BIOS 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]].
  
Booting is a multi-stage process. The MBR is the first 512-byte sector on any hard drive -- it is '''not''' a partition.
+
== History ==
  
 
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 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).
  
"Conventional" MBR code (e.g. Windows/DOS) will check the partition table for one and only one ''active'' partition, read X sectors from this partition and then transfer control to whatever is found. This is why the initial DOS bootloader may not be able to boot an Arch Linux partition; it can only cater for an ''active'', ''primary'' partition.
+
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 [[GRUB|GRand Unified Bootloader (GRUB)]] is the de facto standard bootloader for GNU/Linux, and users are recommended to install it on the MBR to facilitate booting from ''any'' partition, whether it is primary or logical.
+
The [[GRUB|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.
 +
 
 +
- [http://bbs.archlinux.org/viewtopic.php?id=86361 Source]
  
 
== Backup and restoration ==
 
== Backup and restoration ==

Revision as of 16:00, 15 December 2009

Summary help replacing me
An overview of the Master Boot Record; the first sector of a partitioned data storage device.
Available in languages

Template:I18n entry

Related articles
GRUB
GRUB2
LILO

The 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.

History

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.

- Source

Backup and restoration

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.

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

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

Resources