Safekipedia

Bootloader

Discoverer · ages 10+Adapted from Wikipedia
The Windows Boot Manager screen, where a computer user can pick which Windows version to start, such as Windows 7, Windows Vista, or Windows XP.

A bootloader, also spelled boot loader or called bootstrap loader, is a computer program that starts a computer and then starts an operating system. If it also shows a menu with several boot choices, it is often called a boot manager.

When a computer is turned off, its software, including operating systems, application code, and data, stays stored on non-volatile memory. When the computer is powered on, it usually does not have an operating system or its loader in random-access memory (RAM). Instead, the computer first runs a small program stored in the boot ROM, which is read-only memory (ROM, and later EEPROM, NOR flash). This program prepares the hardware, such as the CPU, motherboard, memory, storage, and other input and output devices. It also gets access to the storage device, usually a block device such as NAND flash, from which the operating system programs and data can be loaded into RAM.

GNU GRUB, a popular free-software bootloader

Some earlier computers worked in a simpler way. After receiving a boot signal from a person or a connected device, they loaded a very small set of fixed instructions into memory at a specific location and then started the CPU running them. These instructions usually began reading input from a device, which the operator could sometimes choose with switches. Other systems sent commands directly to devices that carried out a very simple reading task, which loaded a few boot loader instructions into memory.

Smaller computers often use less flexible but more automatic methods. In many desktop computers, the starting process begins with the CPU running software stored in ROM, such as the BIOS (basic input output system) of an IBM PC or an IBM PC compatible. This software is found at a set address, and some CPUs, including the Intel x86 series, are built to run it right after a reset without outside help. The software can search for devices that can take part in starting the computer. It then loads a small program from a special area, most commonly the boot sector, of the most promising device, usually beginning at a fixed entry point such as the start of that sector.

First-stage boot loader

Examples of first-stage bootloaders include BIOS, UEFI, coreboot, Libreboot, and Das U-Boot. A first-stage bootloader sets up hardware parts of the computer, such as the processor, the motherboard, the memory, the storage, and other input and output devices.

Second-stage boot loader

Second-stage boot loaders, such as GNU GRUB, rEFInd, BOOTMGR, Syslinux, and NTLDR, are not operating systems themselves. They can load an operating system and hand control to it. The operating system then starts itself up and may load extra device drivers. These loaders can show a menu where users choose options and change settings. They also load the kernel and can handle initrd/initramfs images.

The menu can offer different operating systems (for dual or multi-booting from different partitions or drives), different versions of the same system, or a safe mode. It can also offer standalone programs such as memtest86+, a basic shell, or games (see List of PC booter games). Some boot loaders load other boot loaders. For example, GRUB loads BOOTMGR instead of loading Windows directly. Usually a default choice is selected, and a short wait lets the user press a key to change it. If no key is pressed, the default starts automatically.

Examples

On x86 computers, the BIOS runs a Power-On Self Test and then starts the first-stage bootloader. This tiny program fits in 512 bytes, sits in the master boot record, and runs in 16-bit real mode. It must find the second-stage bootloader while staying within strict size limits, which leaves little room for the partition table and boot signature in the master boot record. Its code must also work on the original Intel 8088 and Intel 8086 processors. Disk structures may include FAT file system support, and systems may read disks using CHS or logical block addressing. Second-stage bootloaders such as PBR have more room to work, and third-stage bootloaders include IO.SYS, NTLDR, BOOTMGR, and GRUB. UEFI systems do not rely on boot sectors. Instead, they load the next bootloader, such as BOOTMGR or GRUB2, from the EFI System Partition.

On IBM System/360 and its successors, the LOAD operator control starts a process called Initial Program Load. The system resets, reads a small bootstrap record from the device, and then loads the starting program. The operating systems for System/360 through z/Architecture are stored on direct access storage devices, such as disks and drums. For OS/360, the starting program prepares the system, loads the core part of the operating system called the Nucleus, and then hands control to the Nucleus Initialization Program.

Embedded and multi-stage boot loaders

Many embedded systems must start working right away. For example, it is generally not acceptable to wait a minute for a digital television or a GPS navigation device to start. Because of this, these devices keep their software in ROM or flash memory, so they can start working immediately. Little or no loading is needed, since the loading can be worked out in advance and stored on the ROM when the device is made.

Large and complex systems may start up in several steps until the operating system and other programs are loaded and ready to run. The boot loader might load the operating system, set itself up as a simple process inside that system, and then hand over control to the operating system for good. After that, the boot loader ends normally, like any other program. Some boot loaders, such as Das U-Boot and iBoot, include both first- and second-stage boot functions.

Network booting

Main article: Network booting

Most computers can also boot over a computer network. In this case, the operating system is stored on the disk of a server. Certain parts of it are sent to the computer using a simple protocol, such as the Trivial File Transfer Protocol (TFTP). Once those parts arrive, the operating system takes over the starting process.

Like the second-stage boot loader, network booting starts with basic network methods built into the network interface's boot ROM, which usually holds a Preboot Execution Environment (PXE) image. No drivers are needed at first, but the computer can do only limited things until the main part of the operating system and its drivers are sent and started. Because of this, after the ROM-based booting is finished, it is possible to network boot into an operating system that cannot itself use the network interface.

Quiz time!

5 questions about Bootloader

Question 1 of 5

What is the main job of a bootloader?

Pictures

A small serial flash memory chip made by Winbond, found on the circuit board of a Western Digital hard drive.

Keep exploring

This article is a child-friendly adaptation of the Wikipedia article on Bootloader, available under CC BY-SA 4.0.

Images from Wikimedia Commons. Tap any image to view credits and license.