GNU GRUB (short for GNU GRand Unified Bootloader) is a boot loader package from the GNU Project. GRUB is the reference implementation of the 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 was developed from a package called the Grand Unified Bootloader (a play on Grand Unified Theory). It is predominantly used for Unix-like systems. The GNU operating system uses GNU GRUB as its boot loader, as do most Linux distributions. The Solaris operating system has used GRUB as its boot loader on x86 systems, starting with the Solaris 10 1/06 release.
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 the GNU Project and opened the development process to the public.
GRUB is dynamically configurable. It loads its configuration at startup, allowing boot-time changes, such as selecting different kernels or initial RAM disks. To this end, GRUB provides a simple, bash-like, command line interface, which lets users write new boot sequences on the fly, in addition to the normal menu lists.
GRUB is highly portable. It supports multiple executable formats and is geometry translation independent. GRUB supports all commonly used Unix file systems, the Windows file systems VFAT and NTFS, and logical block addressing (LBA). GRUB allows users to view the contents of files on any supported file system.
GRUB can be used with a variety of different user interfaces. Most Linux distributions take advantage of GRUB's support for a graphical interface to provide a customized boot menu with a background image. GRUB's text interface can be modified to use a serial link so that a remote terminal can have access to the boot loader.
GRUB can download operating system images from a network, and thus can support diskless systems. GRUB supports automatic decompression of OS images prior to booting from them.
GRUB uses a scrollable screen for operating system boot selection. This means 150 or more boot choices can be easily controlled by GRUB by adding them to the "menu.lst" configuration file. The arrow keys are used to select which operating system to boot.
GRUB supports operating systems that do not multiboot, by using chain loading. GRUB uses the same two or three lines of command sequences to boot any DOS, Windows, Linux, BSD or Solaris system, making it very easy to work with it. The chain loaders for the supported Unix-like OSes are built into GRUB.
In addition to the normal menu interface, GRUB can provide a bash-like terminal command prompt that provides a rich set of commands to allow a user to view or alter any part of the boot process. With these tools it is possible, without prior knowledge of what is installed on a computer, to use GRUB from an external device such as a floppy disk, USB device or a CD-ROM to boot up an installed operating system.
A GRUB installation for any supported OS can be installed from any of the usual Unix-like operating systems, as well as using specific GRUB implementations for DOS and Windows.
When a computer is turned on, the computer's BIOS finds the primary bootable device (usually the computer's hard disk) and loads the initial bootstrap program from the master boot record (MBR), the first 512 bytes of the hard disk, then transfers control to this code.
GRUB version 1
The MBR usually contains GRUB stage 1, but can contain another bootloader which can chain boot GRUB stage 1 from another boot sector such as a partition's Volume boot record. Given the small size of a boot sector, 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 1024 cylinders).
Stage 1 can load Stage 2 directly, but it is normally set up to load Stage 1.5. GRUB Stage 1.5 is located in the first 30 kilobytes of hard disk immediately following the MBR and before the first partition. If 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 filesystem specific drivers. This enables stage 1.5 to directly load stage 2 from a 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 version 2
This is very similar to Grub version 1: boot.img is stored in the MBR or Volume boot record like Stage 1; however, it can load one sector from any LBA48 address. This loads the first sector of core.img (generated from diskboot.img) which is then used to load the rest of the generated core.img file. The core.img file will normally be stored in the same location as Stage 1.5 with the same problems; however, it can be moved to a file system or bare partition with fewer problems than moving or omitting Stage 1.5.
Once loaded, the core.img file will then load the default configuration file and any other modules needed.
After loading GRUB, but before the operating system starts
Once GRUB has loaded, it presents an interface where the user can select which operating system to boot. This normally takes the form of a graphical menu. If this is not available, or the user wishes direct control, GRUB has its own command prompt. The user can then manually specify the boot parameters. GRUB can be set to automatically load a specified kernel after a user defined timeout.
Perhaps the most important commands that GRUB accepts in the operating system selection (kernel selection) menu are the following two commands.
- By pressing 'e', it is possible to edit parameters for the selected operating system before the operating system is started. Typically, this is used for changing kernel parameters for a Linux system. The reason for doing this in GRUB (i.e. not editing the parameters in an already booted system) can be an emergency case: the system has failed to boot. Using the kernel parameters line it is possible, among other things, to specify a module to be disabled (blacklisted) for the kernel. This could be needed, if the specific kernel module is broken and thus prevents boot-up. Example for blacklisting a kernel module "nvidia-current": append "modprobe.blacklist=nvidia-current" at the end of the kernel parameters. 
- By pressing 'c', the user enters the GRUB command line. This is not a regular Linux shell. It accepts certain GRUB-specific commands.
Once boot options have been selected, GRUB loads the selected kernel into memory and passes control to the kernel. Alternatively, GRUB can pass control of the boot process to another loader, using chain loading. This is the method used to load operating systems such as Windows, that do not support the Multiboot standard or are not supported directly by GRUB. In this case, copies of the other system's boot programs have been saved by GRUB. Instead of a kernel, the other system is loaded as though it had been started from the MBR. This could be another boot manager, such as the Microsoft boot menu, allowing further selection of non-Multiboot operating systems.
A key feature of GRUB is that it can be installed without being attached to an operating system. However, it needs a copy of a Linux image for such an installation. Working as a stand alone system it is virtually a mini system in its own right and able to boot all the installed major operating systems by chain loading, as described above.
Unlike Linux Loader (LILO), there is no need to reinstall GRUB to the MBR or a partition after changes to the configuration file.
In Linux, the "grub-install" command is used to install stage1 to either the MBR or a partition. GRUB's configuration file, stage2 (usually), and other files must be in a usable partition. If these files or the partition become unavailable, stage1 will drop the user to the command line interface.
The name and disk location of the GRUB configuration file varies from system to system. For example, in openSUSE and (for GRUB legacy) in Debian GNU/Linux the file is stored in
/boot/grub/menu.lst while Fedora, Gentoo Linux, and (for GRUB 2) Debian use
../grub.cfg. Fedora also provides a symbolic link from
/boot/grub/grub.conf for FHS compatibility reasons.
GRUB can be installed on removable media, such as an optical drive (BIOS access, and El Torito), floppy disk or USB flash drive, in order to bring up a system that may not have or cannot boot from a hard disk.
The most commonly used version of GRUB is called "GRUB Legacy". This version is still receiving bug fixes, but no new features are being added. The 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 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 project include support for non-x86 platforms, internationalization/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. Ubuntu adopted GRUB 2 as its default boot loader on its 9.10 version.
Since GRUB Legacy is still the most widely used version among end users, but official development is being done on a different version, several other projects maintain their own enhancements (forks) to the GRUB Legacy code. These include Super Grub Disk (new commands include "setgrubdevice" and "usbshift") and GRUB4DOS. GRUB4DOS is a universal boot loader that can boot off DOS/LINUX, or via Windows boot manager/syslinux/lilo, or from MBR/CD. It also has built-in BIOS disk emulation, ATAPI CDROM driver, etc. It has enhanced several commands, including "find --set-root", "map --hook", and "cdrom").
OpenSolaris includes a modified GRUB Legacy that supports BSD disklabels, automatic 64-bit kernel selection, and booting from ZFS (with compression and multiple boot environments). Syllable OS project made a modified version of GRUB to load the system from its AtheOS File System.
GRUB configuration tools
StartUp-Manager, a program used to configure GRUB
The setup tools in use by various distributions often include modules to set up GRUB: for example, so do YaST2 on SUSE/openSUSE distributions and Anaconda on Fedora/RHEL distributions. StartUp-Manager is a graphical configuration editor for Debian based distributions of GRUB. For GRUB 2 there are KDE Control Modules  . GRLDR ICE is a tiny tool for modifying the default configuration of grldr file for GRUB4DOS.
GRUB Utilities is a collection of multi-platform utilities for GRUB Legacy, GRUB2 and GRUB for DOS.
- Comparison of boot loaders
ar: ca:GRUB cs:GRUB de:Grand Unified Bootloader et:GRUB es:GNU GRUB eu:Grub fa: fr:GNU GRUB ko:GRUB it:GRUB he:GRUB hu:GNU GRUB ml: nl:GRUB ja:GRUB no:GNU Grand Unified Boot loader nn:GNU Grand Unified Boot loader pl:GRUB pt:GRUB ru:GRUB simple:GNU GRUB fi:GNU GRUB sv:GRUB tr:Grub uk:GRUB zh:GNU GRUB