Jump to content

Bootloader

From Wikipedia, the free encyclopedia
GNU GRUB, a popular open source bootloader
Windows bootloader

Abootloader,also spelled asboot loader[1][2]or calledbootstrap loader,is acomputer programthat is responsible forbootinga computer. If it also provides an interactive menu with multiple boot choices then it's often called aboot manager.[2]

When a computer is turned off, its software‍—including operating systems, application code, and data‍—remains stored onnon-volatile memory.When the computer is powered on, it typically does not have an operating system or its loader inrandom-access memory(RAM). The computer first executes a relatively small program stored inread-only memory(ROM, and laterEEPROM,NOR flash) along with some needed data, to initialize RAM (especially on x86 systems), to access the nonvolatile device (usuallyblock device,e.g., NAND flash) or devices from which the operating system programs and data can be loaded into RAM.

Some earlier computer systems, upon receiving a boot signal from a human operator or a peripheral device, may load a very small number of fixed instructions into memory at a specific location, initialize at least one CPU, and then point the CPU to the instructions and start their execution. These instructions typically start an input operation from some peripheral device (which may be switch-selectable by the operator). Other systems may send hardware commands directly to peripheral devices or I/O controllers that cause an extremely simple input operation (such as "read sector zero of the system device into memory starting at location 1000" ) to be carried out, effectively loading a small number of boot loader instructions into memory; a completion signal from the I/O device may then be used to start execution of the instructions by the CPU.

Smaller computers often use less flexible but more automatic boot loader mechanisms to ensure that the computer starts quickly and with a predetermined software configuration. In many desktop computers, for example, the bootstrapping process begins with the CPU executing software contained in ROM (for example, theBIOSof anIBM PCor anIBM PC compatible) at a predefined address (some CPUs, including the Intelx86 series,are designed to execute this software after reset without outside help). This software contains rudimentary functionality to search for devices eligible to participate in booting, and load a small program from a special section (most commonly theboot sector) of the most promising device, typically starting at a fixedentry pointsuch as the start of the sector.

First-stage boot loader[edit]

Boot loaders may face peculiar constraints, especially in size; for instance, on the earlier IBM PC and compatibles, a boot sector should typically work with 510 bytes of code (or less) and in only 32 KiB[3][4](later relaxed to 64 KiB[5]) of system memory and only use instructions supported by the original8088/8086processors. The first stage of PC boot loaders (FSBL, first-stage boot loader) located onfixed disksandremovable drivesmust fit into the first 446bytesof theMaster boot recordin order to leave room for the default 64-bytepartition tablewith four partition entries and the two-byteboot signature,which the BIOS requires for a proper boot loader — or even less, when additional features like more than four partition entries (up to 16 with 16 bytes each), adisk signature(6 bytes), adisk timestamp(6 bytes), anAdvanced Active Partition(18 bytes) or specialmulti-bootloaders have to be supported as well in some environments.

Infloppyandsuperfloppyvolume boot records,up to 59 bytes are occupied for theextended BIOS parameter blockonFAT12andFAT16volumes since DOS 4.0, whereas theFAT32EBPB introduced with DOS 7.1 requires even 87 bytes, leaving only 423 bytes for the boot loader when assuming a sector size of 512 bytes. Microsoft boot sectors, therefore, traditionally imposed certain restrictions on the boot process. For example, the boot file had to be located at a fixed position in the root directory of the file system and stored within consecutive sectors,[6][7]conditions taken care of by theSYScommand and slightly relaxed in later versions of DOS.[7][nb 1]The boot loader was then able to load the first three sectors of the file into memory, which happened to contain another embedded boot loader able to load the remainder of the file into memory.[7]When Microsoft addedLBAand FAT32 support, they switched to a boot loader reaching overtwophysical sectors, using 386 instructions for size reasons. At the same time, other vendors managed to squeeze much more functionality into a single boot sector without relaxing the original constraints on only minimal available memory (32 KiB) and processor support (8088/8086).[nb 2]For example, DR-DOS boot sectors are able to locate the boot file in the FAT12, FAT16 and FAT32 file systems, and load it into memory as a whole viaCHSor LBA, even if the file is not stored in a fixed location and in consecutive sectors.[8][3][9][10][11][nb 3][nb 2]

BIOSandUEFIcan not only load multipleoperating systemsfrom a non-volatile device, they can also initialize system hardware for the loaded operating systems.

Examples of first-stage bootloaders includeBIOS,UEFI,coreboot,Libreboot,andDas U-Boot.

Second-stage boot loader[edit]

Second-stage boot loaders, such asGNU GRUB,rEFInd,BOOTMGR,Syslinux,NTLDRoriBoot,are not themselves operating systems, but are able to load an operating system properly and transfer execution to it; the operating system subsequently initializes itself and may load extradevice drivers.The second-stage boot loader does not need drivers for its own operation, but may instead use generic storage access methods provided by system firmware such as the BIOS orOpen Firmware,though typically with restricted hardware functionality and lower performance.[12]

Many boot loaders can be configured to give the user multiple booting choices. These choices can include different operating systems (fordual or multi-bootingfrom different partitions or drives), different versions of the same operating system (in case a new version has unexpected problems), different operating system loading options (e.g., booting into a rescue orsafe mode), and some standalone programs that can function without an operating system, such as memory testers (e.g.,memtest86+), a basic shell (as in GNU GRUB), or even games (seeList of PC Booter games).[13]Some boot loaders can also load other boot loaders; for example, GRUB loads BOOTMGR instead of loading Windows directly. Usually, a default choice is preselected with a time delay during which a user can press a key to change the choice; after this delay, the default choice is automatically run so normal booting can occur without interaction.

The boot process can be considered complete when the computer is ready to interact with the user, or the operating system is capable of running system programs or application programs.

Embedded and multi-stage boot loaders[edit]

Manyembedded systemsmust boot immediately. For example, waiting a minute for adigital televisionor aGPS navigation deviceto start is generally unacceptable. Therefore, such devices have software systems in ROM orflash memoryso the device can begin functioning immediately; little or no loading is necessary, because the loading can be precomputed and stored on the ROM when the device is made.

Large and complex systems may have boot procedures that proceed in multiple phases until finally the operating system and other programs are loaded and ready to execute. Because operating systems are designed as if they never start or stop, a boot loader might load the operating system, configure itself as a mere process within that system, and then irrevocably transfer control to the operating system. The boot loader then terminates normally as any other process would.

Network booting[edit]

Most computers are also capable of booting over acomputer network.In this scenario, the operating system is stored on the disk of aserver,and certain parts of it are transferred to the client using a simple protocol such as theTrivial File Transfer Protocol(TFTP). After these parts have been transferred, the operating system takes over the control of the booting process.

As with the second-stage boot loader, network booting begins by using generic network access methods provided by the network interface's boot ROM, which typically contains aPreboot Execution Environment(PXE) image. No drivers are required, but the system functionality is limited until the operating system kernel and drivers are transferred and started. As a result, once the ROM-based booting has completed it is entirely possible to network boot into an operating system that itself does not have the ability to use the network interface.

See also[edit]

Notes[edit]

  1. ^ThePC DOS 5.0manual incorrectly states that the system files no longer need to be contiguous. However, for the boot process to work the system files still need to occupy the first two directory entries and the first three sectors ofIBMBIO.COMstill need to be stored contiguously.SYScontinues to take care of these requirements.
  2. ^abAs an example, while the extended functionality of DR-DOSMBRsandboot sectorscompared to theirMS-DOS/PC DOScounterparts could still be achieved utilizing conventionalcode optimizationtechniques up to7.05,for the addition ofLBA,FAT32andLOADERsupport the7.07sectors had to resort toself-modifying code,opcode-level programming, controlled utilization ofside effects,multi-level data/codeoverlappingand algorithmicfoldingtechniques to squeeze everything into a single physical sector, as it was a requirement forbackward- and cross-compatibility with other operating systems inmulti-bootandchain loadscenarios.
  3. ^There is one exception to the rule thatDR-DOSVBRswill load the wholeIBMBIO.COMfile into memory: If theIBMBIO.COMfile is larger than some 29 KB, trying to load the whole file into memory would result in the boot loader tooverwritethestackandrelocateddisk parameter table (DPT/FDPB). Therefore, aDR-DOS 7.07VBR would only load the first 29 KB of the file into memory, relying on another loader embedded into the first part ofIBMBIO.COMto check for this condition and load the remainder of the file into memory by itself if necessary. This does not cause compatibility problems, asIBMBIO.COM's size never exceeded this limit in previous versions without this loader. Combined with a dual entry structure this also allows the system to be loaded by aPC DOSVBR, which would load only the first three sectors of the file into memory.

References[edit]

  1. ^"GNU GRUB - GNU Project - Free Software Foundation (FSF)".www.gnu.org.Retrieved27 September2021.
  2. ^ab"systemd-boot".www.freedesktop.org.Retrieved27 September2021.
  3. ^abPaul, Matthias R. (2 October 1997) [29 September 1997]."Caldera OpenDOS 7.01/7.02 Update Alpha 3 IBMBIO.COM - README.TXT and BOOT.TXT - A short description of how OpenDOS is booted".Archived fromthe originalon 4 October 2003.Retrieved29 March2009.[1]
  4. ^Sakamoto, Masahiko (13 May 2010)."Why BIOS loads MBR into 7C00h in x86?".glamenv-septzen.net.Retrieved22 August2012.
  5. ^Compaq computer corporation; Phoenix technologies ltd; Intel corporation (11 January 1996)."BIOS boot specification 1.01"(PDF).Retrieved21 December2017.
  6. ^Zbikowski, Mark;Allen, Paul;Ballmer, Steve;Borman, Reuben; Borman, Rob; Butler, John; Carroll, Chuck; Chamberlain, Mark; Chell, David; Colee, Mike; Courtney, Mike; Dryfoos, Mike; Duncan, Rachel; Eckhardt, Kurt; Evans, Eric; Farmer, Rick;Gates, Bill;Geary, Michael; Griffin, Bob; Hogarth, Doug; Johnson, James W.; Kermaani, Kaamel; King, Adrian; Koch, Reed; Landowski, James; Larson, Chris; Lennon, Thomas; Lipkie, Dan;McDonald, Marc;McKinney, Bruce; Martin, Pascal; Mathers, Estelle; Matthews, Bob; Melin, David; Mergentime, Charles; Nevin, Randy; Newell, Dan; Newell, Tani; Norris, David; O'Leary, Mike;O'Rear, Bob;Olsson, Mike; Osterman, Larry; Ostling, Ridge; Pai, Sunil;Paterson, Tim;Perez, Gary; Peters, Chris;Petzold, Charles;Pollock, John; Reynolds, Aaron; Rubin, Darryl; Ryan, Ralph; Schulmeisters, Karl; Shah, Rajen; Shaw, Barry; Short, Anthony; Slivka, Ben; Smirl, Jon; Stillmaker, Betty; Stoddard, John; Tillman, Dennis; Whitten, Greg; Yount, Natalie; Zeck, Steve (1988). "Technical advisors".The MS-DOS Encyclopedia: versions 1.0 through 3.2.By Duncan, Ray; Bostwick, Steve; Burgoyne, Keith; Byers, Robert A.; Hogan, Thom; Kyle, Jim;Letwin, Gordon;Petzold, Charles;Rabinowitz, Chip; Tomlin, Jim; Wilton, Richard; Wolverton, Van; Wong, William; Woodcock, JoAnne (Completely reworked ed.). Redmond, Washington, USA:Microsoft Press.ISBN1-55615-049-0.LCCN87-21452.OCLC16581341.(xix+1570 pages; 26 cm) (NB. This edition was published in 1988 after extensive rework of the withdrawn 1986 first edition by a different team of authors.[2])
  7. ^abcChappell, Geoff (January 1994). "Chapter 2: The system footprint". In Schulman, Andrew; Pedersen, Amorette (eds.).DOS Internals.The Andrew Schulman programming series (1st printing, 1st ed.).Addison-Wesley.ISBN978-0-201-60835-9.(xxvi+738+iv pages, 3.5 "-floppy[3][4]) Errata:[5][6][7]
  8. ^Rosch, Winn L. (12 February 1991)."DR DOS 5.0 - The better operating system?".PC Magazine.Vol. 10, no. 3. pp. 241–246, 257, 264, 266.Archivedfrom the original on 25 July 2019.Retrieved26 July2019.[…]SYShas been improved underDR DOS 5.0so you don't have to worry about leaving the first cluster free on a disk that you want to make bootable. The DR DOS system files can be located anywhere on the disk, so any disk with enough free space can be set to boot your system. […](NB. The source attributes this to theSYSutility while in fact this is a feature of the advanced bootstrap loader in the boot sector.SYSjust plants this sector onto the disk.)
  9. ^Paul, Matthias R. (17 January 2001)."FAT32 in DR-DOS".opendos@delorie.Archivedfrom the original on 6 October 2017.Retrieved6 October2017.[…] TheDR-DOSboot sector […] searches for theIBMBIO.COM(DRBIOS.SYS) file and then loads the *whole* file into memory before it passes control to it. […]
  10. ^Paul, Matthias R. (20 February 2002)."Can't copy".opendos@delorie.Archivedfrom the original on 6 October 2017.Retrieved9 October2017.[…] TheDR-DOSboot sector loads the wholeIBMBIO.COMfile into memory before it executes it. It does not care at all about theIBMDOS.COMfile, which is loaded byIBMBIO.COM.[…] The DR-DOS boot sector […] will find the […] kernel files as long as they are logically stored in the root directory. Their physical location on the disk, and if they are fragmented or not, is don't care for the DR-DOS boot sector. Hence, you can just copy the kernel files to the disk (even with a simplyCOPY), and as soon as the boot sector is a DR-DOS sector, it will find and load them. Of course, it is difficult to put all this into just 512 bytes, the size of a single sector, but this is a major convenience improvement if you have to set up a DR-DOS system, and it is also the key for the DR-DOS multi-OSLOADERutility to work. TheMS-DOSkernel files must reside on specific locations, but the DR-DOS files can be anywhere, so you don't have to physically swap them around each time you boot the other OS. Also, it allows to upgrade a DR-DOS system simply by copying the kernel files over the old ones, no need forSYS,no difficult setup procedures as required for MS-DOS/PC DOS.You can even have multiple DR-DOS kernel files under different file names stored on the same drive, and LOADER will switch between them according to the file names listed in theBOOT.LSTfile. […]
  11. ^Paul, Matthias R. (14 August 2017) [7 August 2017]."The continuing saga of Windows 3.1 in enhanced mode on OmniBook 300".MoHPC - the museum of HP calculators.Archivedfrom the original on 6 October 2017.Retrieved6 October2017.[…] theDR-DOSFDISKdoes not only partition a disk, but can also format the freshly created volumes and initialize their boot sectors in one go, so there's no risk to accidentally mess up the wrong volume and no need forFORMAT/SorSYS.Afterwards, you could just copy over the remaining DR-DOS files, including the system files. It is important to know that, in contrast toMS-DOS/PC DOS,DR-DOS has "smart" boot sectors which will actually "mount" the file-system to search for and load the system files in the root directory instead of expecting them to be placed at a certain location. Physically, the system files can be located anywhere and also can be fragmented. […]
  12. ^"Chapter 6 - Troubleshooting startup and disk problems".Windows NT server resource kit.Microsoft. Archived fromthe originalon 15 May 2007.
  13. ^"Tint".coreboot.Retrieved20 November2010.

External links[edit]