Boot Sector Layout
The DOS boot sector of a floppy disk or a hard disk partition is expected
to be in this format. Prior to DOS 4.0, a smaller structure was used (see
notes, below).
BootSectorRec
Offset Size Contents
▀▀▀▀▀▀ ▀▀▀▀ ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
+0 3 abJmpCode JMP opcode to start of boot code
+3 8 abOem e.g., "MSDOS6.0" or "IBM 4.0"
+0bH 2 wSectSize bytes per sector (usually 512; 200H)
+0dH 1 bClustSects sectors per allocation unit (cluster)
+0eH 2 wResSects boot and reserved sectors
+10H 1 bFatCnt number of File Allocation Tables. See FAT.
+11H 2 wRootEntries max number of 32-byte DirEntryRecs in root
+13H 2 wTotSects total number of sectors in media
0000H means >32 MB, so use lBigTotSects
+15H 1 bMedia media descriptor (same as 1st byte in FAT)
+16H 2 wFatSects number of sectors in one FAT
+18H 2 wSectsPerTrk sectors per track
+1aH 2 wHeads number of read/write heads
+1cH 4 lHidSects hidden sectors (ignore hiword in pre-DOS 4.0)
+20H 4 lBigTotSects 32-bit TotSects in volume (partitions > 32M)
+24H 1 bDrvNo 80H=first hard disk (used internally by DOS)
+25H 1 res1 (reserved)
+26H 1 bExtBootSig Extended boot record signature (always 29H)
+27H 4 lSerNo Volume Serial Number (based on when formatted)
+2bH 11 abVolLabel Volume Label (11-character, blank padded)
+36H 8 abFileSysID contains 'FAT12 ' or 'FAT16 ')
62 length of formatted portion of BootSectorRec
+3eH ? abBootCode code and data that performs disk bootstrap
+2ffH end of boot sector
See BPBRec for a description of most of these fields. Fields unique to
the BootSectorRec include:
abJmpCode Since the Boot Sector is used as program code during system
startup, the first bytes in the sector are a JMP opcode to get
past the data area. It usually jumps to abBootCode.
abOem This is an 8-character text field that is supposed to contain
the signature of the version of DOS which formatted the disk
(or otherwise laid down the boot sector). It is not used by
DOS.
bDrvNo On the first hard disk in a system, this field contains 80H.
Otherwise it should be 00H. Used internally by DOS.
bExtBootSig Prior to DOS 4.0, the formatted portion of the Boot Sector
ended at offset 1eH and that variation is still supported.
Boot Sectors which contain 29H in this field (offset 26H) are
expected to contain the entire 3eH-byte record.
lSerNo a 32-bit volume serial number. It is based on the time and
date when formatted, making the disk unique for the system
which formatted it. This field is used by block device
drivers which support Removable Media and Change Line
functions (see Device Requests and fn 44H).
On disks formatted by DOS versions prior to 4.0, there is no
lSerNo or abVolLabel fields. On pre-formatted diskettes,
these fields are often non-unique. In either case, DOS might
not be able to detect a disk swap.
abVolLabel the 11-character, blank-padded, volume label. DOS lays this
down when the disk is formatted AND DOS updates it (along with
the volume label entry in the root directory) when you use the
Label command.
abFileSysID this 8-character, blank-padded text field identifies the file
system. It can be 'FAT12 ' (12-bit FAT entries) or
'FAT16 ' (16-bit FAT entries). See File Allocation Table.
abBootCode this is the start of the unformatted portion of the boot
sector. It contains data and code that is executed when the
disk is booted.
Versions: ■ DOS 2.x: the formatted part of the record ended at offset 18H.
■ DOS 3.x: the formatted part of the record ended at offset 1eH.
■ DOS 4.0+: bExtBootSig contains 29H and all fields through
offset 3eH are used.
Notes: ■ Use absolute disk read INT 25H (DX=0) to read this sector OR
• floppy disks: The boot sector is at BIOS INT 13H head 0,
track 0, sector 1
• hard disks: read the Partition Table to determine BIOS Head,
Track, Sector to seek before using INT 13H.
■ To convert a cluster number (as read from the wClustNo field of
a Directory Entry or a FAT chain) into a absolute sector number
(as used in INT 25H/26H calls), you may use DOS Fn 32H or read
the Boot Sector and apply the formulae:
wRootSects = (wRootEntries * 32) / wSectSize
wFirstData = wResSects + (wFatSects * bFatCnt) + wRootSects
lAbsSector = wFirstData + ((lAnyClusterNo - 2) * bClustects)
Use the calculated value (lAbsSector) in INT 25H or INT 26H
calls.
■ Very old hard disks which require an installed device driver
(non-bootable hard disks) may contain garbage in the boot
sector. When possible, use DOS fns such as 32H to obtain
information about the device.
See Also: Partition Table
File Allocation Table
Device Drivers
-♦-