Misplaced Pages

GNU GRUB

Article snapshot taken from Wikipedia with creative commons attribution-sharealike license. Give it a read and then ask your questions in the chat. We can research this topic together.

A bootloader , also spelled as boot loader or called bootstrap loader , is a computer program that is responsible for booting a computer. If it also provides an interactive menu with multiple boot choices then it's often called a boot manager .

#864135

54-585: GNU GRUB (short for GNU GRand Unified Bootloader , commonly referred to as GRUB ) is a boot loader package from the GNU Project . GRUB is the reference implementation of the Free Software Foundation 's Multiboot Specification , which provides a user the choice to boot one of multiple operating systems installed on a computer or select a specific kernel configuration available on a particular operating system's partitions. GNU GRUB

108-546: A UUID to uniquely identify an instance. The UUID is created when a partition is formatted. The UUID is part of the file system and written to the superblock . All operations other than formatting should leave the UUID unaltered. It is possible to change the UUID or duplicate it by using dd to clone an entire partition. The file grub.cfg is used to configure GRUB. It contains commands to be executed during each start-up. Without an existing and valid grub.cfg , GRUB will present

162-631: A basic shell (as in GNU GRUB), or even games (see List of PC booter games ). 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. They may also handle compression, cryptographic verification, and chain-loading of other bootloaders. The boot process can be considered complete when

216-507: A boot loader reaching over two physical 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). 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

270-452: A driver for each of the supported file systems, so they can be understood and accessed by the boot loader itself. This approach eliminates the need for hardcoded locations of hard disk sectors and existence of map files, and does not require MBR updates after kernel images are added or moved around. The configuration of a boot loader is stored in a regular file, which is also accessed in a file system-aware way to obtain boot configurations before

324-446: A menu where the user can choose from operating systems (OS) found by grub-install. GRUB can be configured to automatically load a specified OS after a user-defined timeout. If the timeout is set to zero seconds, pressing and holding ⇧ Shift while the computer is booting makes it possible to access the boot menu. In the operating system selection menu GRUB accepts a couple of commands: Once boot options have been selected, GRUB loads

378-400: 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. Most computers are also capable of booting over a computer network . In this scenario, the operating system is stored on the disk of a server , and certain parts of it are transferred to the client using a simple protocol such as

432-426: A new program, using a common data area to pass information from the current program to the new program. It occurs in several areas of computing. Chain loading is similar to the use of overlays . Unlike overlays, however, chain loading replaces the currently executing program in its entirety. Overlays usually replace only a portion of the running program. Like the use of overlays, the use of chain loading increases

486-485: A prompt. An absolute minimal grub.cfg might contain only the following two commands (cf. initial ramdisk ): A fancier grub.cfg will describe a menu to be presented, use multiple colors, and may specify a background picture. GRUB was initially developed by Erich Boleyn as part of work on booting the operating system GNU / Hurd , developed by the Free Software Foundation . In 1999, Gordon Matzigkeit and Yoshinori K. Okuji made GRUB an official software package of

540-428: A single sector. For a long time, the size of a sector has been 512 bytes. Since 2009 there are hard disks available with a sector size of 4096 bytes, called Advanced Format disks, but as of October 2013, such hard disks are still accessed in 512-byte sectors, using the 512e emulation . The legacy MBR partition table supports a maximum of four partitions and occupies 64 bytes, combined. Together with

594-430: A whole via CHS or LBA, even if the file is not stored in a fixed location and in consecutive sectors. BIOS and UEFI can not only load multiple operating systems from a non-volatile device, they can also initialize system hardware for the loaded operating systems. Examples of first-stage bootloaders include BIOS , UEFI , coreboot , Libreboot , and Das U-Boot . Second-stage bootloaders operate without

SECTION 10

#1732783611865

648-523: Is a compact 512-byte program that resides in the master boot record (MBR) and executes when a computer starts. Running in 16-bit real mode at address 0x7C00, it performs minimal hardware initialization , sets up a basic execution environment , and locates the second-stage bootloader. Its primary challenge lies in accomplishing these tasks within strict size constraints while handling potential hardware failures. The bootloader must navigate disk structures, often implementing FAT file system support, and manage

702-419: Is available under GNU GPL license . Boot-Repair can repair GRUB on multiple Linux distributions including, but not limited to, Debian, Ubuntu, Mint , Fedora, openSUSE, and Arch Linux . Grub2Win is a Windows open-source software package. It allows GNU GRUB to boot from a Windows directory. The setup program installs GNU GRUB version 2.12 to an NTFS partition. A Windows GUI application is then used to customize

756-458: 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

810-419: Is only prevalent in older releases of Linux distributions. GRUB 2 was written from scratch and intended to replace its predecessor, and is now used by a majority of Linux distributions. GRUB 0.x follows a two-stage approach. The master boot record (MBR) usually contains GRUB stage 1, or can contain a standard MBR implementation which chainloads GRUB stage 1 from the active partition's boot sector . Given

864-412: Is required, in form of maps or map files  – auxiliary files that contain a list of physical sectors occupied by kernel images. Such maps need to be updated each time a kernel image changes its physical location on disk, due to installing new kernel images, file system defragmentation, etc. Also, in case of the maps changing their physical location, their locations need to be updated within

918-601: Is the purview of the CHAIN statement (or, in Commodore BASIC , the LOAD statement), which causes the current program to be terminated and the chained-to program to be loaded and invoked (with, on those dialects of BASIC that support it, an optional parameter specifying the line number from which execution is to commence, rather than the default of the first line of the new program). The common data area varies according to

972-517: The GNU Project and opened the development process to the public. As of 2014, the majority of Linux distributions have adopted GNU GRUB 2, as well as other systems such as Sony's PlayStation 4 . GRUB version 0 (also known as "GRUB Legacy") is no longer under development and is being phased out. The GNU GRUB developers have switched their focus to GRUB 2, a complete rewrite with goals including making GNU GRUB cleaner, more robust, more portable and more powerful. GRUB 2 started under

1026-556: The GRUB console (available after loading normal.mod ) a list of all available hard disks and partitions can be obtained. For example, ls (hd0,5)/ ) will show numbers that can be assigned to actual hard disks and partitions. As it cannot be guaranteed that the " hd0" style numbering of hard disks via device numbers is consistent, GNU GRUB can use a Universally Unique Identifier (UUID) to identify partitions (actually file system instances). The file systems ext2, ext3, ext4 and xfs use

1080-550: The I/O load of an application. In operating system boot manager programs, chain loading is used to pass control from the boot manager to a boot sector . The target boot sector is loaded in from disk , replacing the in-memory boot sector from which the boot manager itself was bootstrapped, and executed. In Unix (and in Unix-like operating systems), the exec() system call is used to perform chain loading. The program image of

1134-487: The Trivial 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 a Preboot Execution Environment (PXE) image. No drivers are required, but

SECTION 20

#1732783611865

1188-464: The extended BIOS parameter block on FAT12 and FAT16 volumes since DOS 4.0, whereas the FAT32 EBPB 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

1242-530: The kernel . Many implement modular designs supporting loadable modules for additional functionality. These choices can include different operating systems (for dual or multi-booting from 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 or safe mode ), and some standalone programs that can function without an operating system, such as memory testers (e.g., memtest86+ ),

1296-482: The GRUB boot menu, themes, UEFI boot order, scripts etc. All GNU GRUB scripts and commands are supported for both UEFI and legacy systems. Grub2Win can configure GRUB for multiboot of Windows, Ubuntu, openSuse, Fedora and many other Linux distributions. It is freely available under GNU GPL License at SourceForge . The strength of GRUB is the wide range of supported platforms, file systems, and operating systems, making it

1350-471: The Intel x86 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 the boot sector ) of the most promising device, typically starting at a fixed entry point such as the start of the sector. A first-stage bootloader

1404-469: The actual booting of any kernel images. Thus, fewer things can go wrong during system updates. As a downside, such boot loaders are larger and more complex. GNU GRUB uses the second approach, by understanding the underlying file systems. The boot loader itself is split into multiple stages so that it fits in the MBR boot scheme. Two major versions of GRUB are in common use: GRUB version 0, called GRUB legacy,

1458-419: The boot loader's MBR code, so the sectors indirection mechanism continues to work. This is not only cumbersome, but it also leaves the system in need of manual repairs in case something goes wrong during system updates. Another approach is to make a boot loader aware of the underlying file systems, so kernel images are configured and accessed using their actual file paths . That requires a boot loader to contain

1512-446: The computer POSTs , the hard disk connected to a specific motherboard port could be assigned the same identifier, for example hd0, hd1, … . But what if such consistency cannot be guaranteed? What if the constellation of connected hard disks changed from one start up to another? What if a hard disk will be connected to another computer? By entering ls into either the GRUB rescue console (available after loading core.img ) or

1566-418: The computer is powered on, it typically does not have an operating system or its loader in random-access memory (RAM). The computer first executes a relatively small program stored in read-only memory (ROM, and later EEPROM , NOR flash ) along with some needed data, to initialize RAM (especially on x86 systems), to access the nonvolatile device (usually block device , e.g., NAND flash) or devices from which

1620-450: The computer is ready to interact with the user, or the operating system is capable of running system programs or application programs. Many embedded systems must boot immediately. For example, waiting a minute for a digital television or a GPS navigation device to start is generally unacceptable. Therefore, such devices have software systems in ROM or flash memory so the device can begin functioning immediately; little or no loading

1674-556: The concept of a file system is unknown to the BIOS. Thus, in BIOS-based systems, the duty of a boot loader is to access the content of those files, so it can be loaded into the RAM and executed. One possible approach for boot loaders is to load kernel images by directly accessing hard disk sectors without understanding the underlying file system. Usually, an additional level of indirection

GNU GRUB - Misplaced Pages Continue

1728-544: The current process is replaced with an entirely new image, and the current thread begins execution of that image. The common data area comprises the process' environment variables , which are preserved across the system call. In addition to the exec() process level chain loading Linux supports the kexec () system call to replace the entire operating system kernel with a different version. The new kernel boots as if it were started from power up and no running processes are preserved. In BASIC programs, chain loading

1782-522: The default choice for distributions and embedded systems. However, there are boot managers targeted at the end user that give more friendly user experience, graphical OS selector and simpler configuration: Non-graphical alternatives: Distribution wikis have many solutions for common issues and custom setups that might help you: Boot loader When a computer is turned off, its software‍—‌including operating systems, application code, and data‍—‌remains stored on non-volatile memory . When

1836-565: The delicate transition from the BIOS startup state to a stable environment for the next boot stage. 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 (later relaxed to 64 KiB ) of system memory and only use instructions supported by the original 8088 / 8086 processors. The first stage of PC boot loaders (FSBL, first-stage boot loader) located on fixed disks and removable drives must fit into

1890-614: The first 446 bytes of the master boot record in order to leave room for the default 64-byte partition table with four partition entries and the two-byte boot 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), a disk signature (6 bytes), a disk timestamp (6 bytes), an Advanced Active Partition (18 bytes) or special multi-boot loaders have to be supported as well in some environments. In floppy and superfloppy volume boot records , up to 59 bytes are occupied for

1944-432: The first partition. In case this space is not available (unusual partition table, special disk drivers, GPT or LVM disk) the install of stage 1.5 will fail. The stage 1.5 image contains file system drivers, enabling it to directly load stage 2 from any known location in the filesystem, for example from /boot/grub . Stage 2 will then load the default configuration file and any other modules needed. GRUB presents

1998-540: 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, the BIOS of an IBM PC or an IBM PC compatible ) at a predefined address (some CPUs, including

2052-447: The lead developer cited personal reasons for not actively developing the program. GRUB Customizer is also available for Arch-based distributions. For GRUB 2 there are KDE Control Modules. GRLDR ICE is a tiny tool for modifying the default configuration of grldr file for GRUB4DOS. Boot-Repair is a simple graphical tool for recovering from frequent boot-related problems with GRUB and Microsoft Windows bootloader. This application

2106-757: The name PUPA . PUPA was supported by the Information-technology Promotion Agency (IPA) in Japan. PUPA was integrated into GRUB 2 development around 2002, when GRUB version 0.9x was renamed GRUB Legacy. Some of the goals of the GRUB ;2 project include support for non-x86 platforms , internationalization and localization , non-ASCII characters, dynamic modules, memory management , a scripting mini-language , migrating platform specific (x86) code to platform specific modules, and an object-oriented framework. GNU GRUB version 2.00

2160-473: 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

2214-601: The operating system subsequently initializes itself and may load extra device 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 or Open Firmware , though typically with restricted hardware functionality and lower performance. Second-stage implementations can include interactive user interfaces, allowing boot option selection and parameter modification. They handle kernel loading, including processing of initrd/initramfs images, and can pass boot parameters to

GNU GRUB - Misplaced Pages Continue

2268-463: 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

2322-459: The optional disk signature (four bytes) and disk timestamp (six bytes), this leaves between 434 and 446 bytes available for the machine code of a boot loader. Although such a small space can be sufficient for very simple boot loaders, it is not big enough to contain a boot loader supporting complex and multiple file systems , menu-driven selection of boot choices, etc. Boot loaders with bigger footprints are therefore split into pieces, where

2376-603: The particular dialect of BASIC that is in use. On BBC BASIC , for example, only a specific subset of all variables are preserved across a CHAIN. On other BASICs, the COM statement can be used in conjunction with CHAIN to specify which variables are to be preserved as common data across a chain operation. Chain loading permits BASIC programs to execute more program code than could fit into available program and variable memory. Applications written in BASIC could thus be far larger than

2430-480: The root directory of the file system and stored within consecutive sectors, conditions taken care of by the SYS command and slightly relaxed in later versions of DOS. 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. When Microsoft added LBA and FAT32 support, they switched to

2484-501: The selected kernel into memory and passes control to the kernel. Alternatively, GRUB can pass control of the boot process to another boot loader, using chain loading . This is the method used to load operating systems that do not support the Multiboot Specification or are not supported directly by GRUB. A computer can have multiple hard disks connected to it. These could be identified via their SATA port. Each time

2538-486: The size of working memory, via a set of cooperating programs that CHAIN back and forth amongst themselves as program flow moves within the overall application. Many versions of Fortran include a CALL CHAIN or CALL LINK statement that performs chain loading, preserving the contents of COMMON storage . This is not the same as the unrelated LINK subroutine in GNU Fortran . OS/360 and successors use

2592-402: The small size of a boot sector (512 bytes), stage 1 can do little more than load the next stage of GRUB by loading a few disk sectors from a fixed location near the start of the disk (within its first 1024 cylinders). Stage 1 can load stage 2 directly, but it is normally set up to load the stage 1.5. , located in the first 30 KiB of hard disk immediately following the MBR and before

2646-460: The smallest piece fits in the MBR, while one or more larger pieces are stored in other locations such as empty sectors between the MBR and the first partition. The code in the MBR then does little more than starting the second part. The purpose of the remaining part(s) of the boot loader is to actually boot an operating system by configuring it and starting the kernel . Kernels are in most cases stored as files residing on appropriate file systems, but

2700-867: The strict 512-byte limitation of their first-stage counterparts. They execute in a more sophisticated environment, typically ranging from 8KB to several megabytes in size. This expanded space allows implementation of complex features including multiple filesystem support, runtime configuration, and bootloader menu interfaces. Second-stage bootloaders perform comprehensive hardware initialization. They query and configure various system components including memory controllers , interrupt controllers , and essential peripherals. Modern implementations often handle ACPI tables, USB controller initialization, and preliminary graphics setup. Second-stage boot loaders, such as GNU GRUB , rEFInd , BOOTMGR , Syslinux , NTLDR or iBoot , are not themselves operating systems, but are able to load an operating system properly and transfer execution to it;

2754-483: 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. Chain loading Chain loading is a method used by computer programs to replace the currently executing program with

SECTION 50

#1732783611865

2808-797: The x86 platform in the Solaris ;11.1 release. Buildroot also uses GNU GRUB for x86 and x86_64 targets. In late 2015, the exploit of pressing backspace 28 times to bypass the login password was found and quickly fixed. GNU GRUB is free software , so several variants have been created. Some notable ones, which have not been merged into GRUB mainline: The setup tools in use by various distributions often include modules to set up GRUB. For example, YaST2 on SUSE Linux and openSUSE distributions and Anaconda on Fedora / RHEL distributions. StartUp-Manager and GRUB Customizer are graphical configuration editors for Debian-based distributions. The development of StartUp-Manager stopped on 6 May 2011 after

2862-528: Was developed from a package called the Grand Unified Bootloader (a play on Grand Unified Theory ). It is predominantly used for Unix-like systems. When a computer is turned on, its BIOS finds the primary bootable device (usually the computer's hard disk) and runs the initial bootstrap program from the master boot record (MBR). The MBR is the first sector of the hard disk. This bootstrap program must be small because it has to fit in

2916-481: Was officially released on June 26, 2012. Three of the most widely used Linux distributions use GRUB 2 as their mainstream boot loader. Ubuntu adopted it as the default boot loader in its 9.10 version of October 2009. Fedora followed suit with Fedora 16 released in November 2011. OpenSUSE adopted GRUB 2 as the default boot loader with its 12.2 release of September 2012. Solaris also adopted GRUB 2 on

#864135