1 Master Boot Record, Booting from USB etc.(8)
2 ============================================
6 mbr - Master Boot Record, Booting from USB etc.
14 This document is work in progress.
17 We are using /dev/sdz as the typical device name. Adjust it to whatever
18 your device corresponds to of course, it's just to prevent any data loss due to
24 The Master Boot Record (MBR) is the first data block with 512 bytes on the x86
25 architecture providing a partition table and a bootloader. In the first 446
26 bytes is the bootcode, providing the bootloader (400 bytes), a disk signature (4
27 bytes) and NULL (2 bytes). The following 64 bytes are the partition table,
28 followed by 2 bytes which are the MBR signature.
33 The bootcode consists of bootloader and disk signature:
38 Windows: ntldr with boot.ini (Windows NT/XP) or bootmgr with \Boot\BCD (Windows Vista)
43 Operating systems like Windows identify the disk using the disk signature.
44 Running 'fixmbr' doesn't touch the disk signature but just the bootloader.
45 Running 'fdisk /mbr' touches the bootloader *and* the disk signature (it writes
46 a standard MBR, it won't touch the partition table though).
47 TODO: what about fixboot?
52 Harddisk addressable: 8GB (Cylinder Head Sector, CHS), 2TB (Logical Block
53 Addressing with 32bit, LBA) or >2TB (GUID Partition Table, GPT)
58 The 2 bytes 55 and AA (both hex), known as the Magic Number. This signature
59 tells the system that there should exist a valid MBR - otherwise you'll get
60 something like "No operating system" or "Non-Bootable Disk".
67 # dd if=/dev/sdz of=mbr_backup.dd bs=512 count=1
69 Restore the MBR again:
71 # dd if=mbr_backup.dd of=/dev/sdz bs=512 count=1
73 Clone MBR *without* partition table:
75 # dd if=/dev/sdz of=mbr_bootcode.dd bs=446 count=1
77 Restore MBR *without* partition table again:
79 # dd if=mbr_bootcode.dd of=/dev/sdz bs=446 count=1
81 Backup partition layout:
83 # sfdisk -d /dev/sdz > backup.sfdisk
85 Restore partition layout again:
87 # sfdisk /dev/sdz < backup.sfdisk
91 lilo -M /dev/sdz -s /dev/null
93 Troubleshooting and Pitfalls when booting
94 -----------------------------------------
96 ///////////////////////////////////////////////////////////
97 TODO: better list type for the error message / reason part?
98 See http://www.methods.co.nz/asciidoc/userguide.html
99 ///////////////////////////////////////////////////////////
102 *Error message*:: ran out of input data. System halted
104 *Reason*:: Everything OK, except for the filesystem used on your usb device. So
105 instead of fat16 you use for example fat32. Fix: use the appropriate filesystem
106 (fat16 for usb pens usually). The Bootsplash might be displayed, the kernel
107 loads but you very soon get the error message.
109 *Error message*:: Invalid operating system
111 *Reason*:: the partition layout is not ok. Very probably there’s no primary
112 partition or none has the flag ‘bootable’ set.
114 *Error message*:: No operating system found.
116 *Reason*:: you forgot to set the boot-flag on the partition. Or there really isn't
117 any operating system at all.
119 *Error message*:: kernel-panic: unable to mount root-fs...
121 *Reason*:: Kernel boots but fails to find the root filesystem. root= argument in
122 your kernel commandline is pointing to the wrong device. Adjust root=...,
123 consider using root=UUID=....
125 *Error message*:: Could not find kernel image: ...
127 *Reason*:: either a broken isolinux/syslinux version or a broken BIOS. Check out
128 whether the vendor provides a BIOS update or if using bootloader grub instead of
129 isolinux/syslinux fixes the problem.
134 * USB-HDD: usually the default and prefered booting mode.
135 * USB-ZIP: ??? - can be set up via:
137 # mkdiskimage -4 /dev/sdz 1 64 32 # device = 1GB
138 # mkdiskimage -4 /dev/sdz 0 128 32 # device >1GB and <=2GB
139 # mkdiskimage -F -4 /dev/sdz 0 255 63 # device >2GB and <=8GB
141 For devices above 8GB (taken from
142 http://www.knoppix.net/wiki/Bootable_USB_Key):
144 # mkdiskimage -F -4 /dev/sdz 1 255 63
145 # dd if=/dev/zero of=/dev/sdz bs=1 seek=446 count=64
146 # echo -e ',0\n,0\n,0\n,,C,*' | sfdisk /dev/sdz
148 USB-ZIP requires to have 64 heads and 32 sectors and less than 1024
156 Check out the *real* difference between:
158 # mbr-install /dev/ice
159 # lilo -S /dev/null -M /dev/ice ext && lilo -S /dev/null -A /dev/ice 1
160 # cat /usr/lib/syslinux/mbr.bin > /dev/ice
162 # syslinux -sf /dev/iceX
163 # mkdiskimage ... (USB-ZIP?)
168 * How does a correct partition look like?
169 * The partition should start behind MBR at 1st cylinder and 63rd sector?
170 * fdisk -l -u /dev/sdz vs. fdisk -l /dev/sdz
175 * http://de.wikipedia.org/wiki/Master_Boot_Record
176 * http://en.wikipedia.org/wiki/Master_boot_record
177 * http://michael-prokop.at/blog/2007/04/22/booting-from-usb-pen-troubleshooting-and-pitfalls/
178 * http://www.ata-atapi.com/hiwmbr.html
179 * http://thestarman.pcministry.com/asm/mbr/index.html