Most PCs made between the late 1980s and around 2008 used boot sectors to help start (boot) your operating system. Even today, most desktop PCs support boot sectors, although they’ve disappeared from many consumer laptops and will probably be gone from all new device by the end of the decade. That’s sad because boot sectors are really quite elegant.
Pre-Boot System Checks And Configuration
The word boot is short for bootstrap. Computer processing units are brains without knowledge—they need instructions to work, so the computer needs a set of instructions to tell itself to start working.
When you press the power button on your older PC, electricity flows through your motherboard to your CPU, but your CPU has no instructions, so your motherboard copies the contents of your Complementary Metal-Oxide-Semiconductor (CMOS) chip into your computer memory and tells your CPU to start running it as a program.
On that CMOS chip was your Basic Input/Output System (BIOS), a tiny operating system which checks to make sure your computer has all the necessary parts. All modern BIOSes also let you set various configuration settings, like what device you want to boot your computer from and which hardware options you want to enable or disable.
When the BIOS finishes its checks, it needs a way to start your operating system (usually Windows). That’s where the boot sector comes in.
Sector 0: Hard Drive Boot Sector
Computer programmers like to start counting from zero, so the first sector of any device is sector zero. On bootable devices, this sector is also the boot sector.
It doesn’t matter whether the device is a magnetic hard disk drive (HDD), a solid state drive (SSD), a USB drive or stick, a CD or DVD, or even an old floppy disk. If the device is marked bootable, the boot sector is the first sector. It is not always a hard drive boot sector.
Your BIOS uses the rules you set to choose a bootable device (usually your primary disk drive) and reads the first sector into your computer’s memory. Then it uses a computer processor command to replace itself with the boot sector stored in memory.
Valid boot sectors are written in assembly language, which is the computer language your computer understands natively. Assembly language for 32-bit Intel processors is pretty easy to understand (if you know programming), so it’s not too difficult to actually figure out what your boot sector does.
One reason it’s so easy is because the boot sector is so small. On traditional computer drives, it’s only 512 bytes—that’s the equivalent of less than 100 typical English words (with spaces between them), or about the twice the size of this entire paragraph.
Although computer programmers are wizards, writing a tiny program to start something as complicated as Windows is really hard, so most boot sectors simply repeat the trick the BIOS performed: they read another part of your hard drive into memory and then replace themselves with that bit of memory.
The second program they load is called your bootloader. In Windows, it’s the screen which lets you choose to start Windows normally after a crash or to start in Safe Mode. In Linux, it’s the screen which lets you choose which Linux kernel to use.
After you make your choice (or have it chosen for you automatically), the bootloader then replaces itself in memory with your operating system kernel. If something goes wrong with the loading process there are ways to fix the boot sector.
I mentioned Windows and Linux, but what about Mac OSX? Mac OSX started out on the PowerPC platform which, despite its name, was very different from Intel-style PCs. Mac PowerPCs didn’t use boot sectors, they used something called OpenFirmware. When Apple switched Macs to Intel hardware, they used a BIOS replacement called Unified Extensible Firmware Interface (UEFI) which doesn’t use boot sectors.
Newer Windows computers are now usually preinstalled with UEFI too, although both Windows 8 and all popular versions of Linux still support a hard drive boot sector and probably will continue to do so for at least another five years.