GNU GRUB
Encyclopedia
GNU GRUB is a boot loader package from the GNU Project
GNU Project
The GNU Project is a free software, mass collaboration project, announced on September 27, 1983, by Richard Stallman at MIT. It initiated GNU operating system development in January, 1984...

. GRUB is the reference implementation
Reference implementation
In the software development process, a reference implementation is the standard from which all other implementations, with their attendant customizations, are measured, and to which all improvements are added...

 of the Multiboot Specification
Multiboot Specification
The Multiboot Specification is an open standard originally created in 1995 and developed by the Free Software Foundation. The specification describes a method of loading various multiboot kernels using a single compliant boot loader. GNU Hurd, VMware ESXi, Xen, and L4 microkernels all need to be...

, which provides a user the choice to boot one of multiple operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

s 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
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 systems. The GNU operating system uses GNU GRUB as its boot loader, as do most Linux distribution
Linux distribution
A Linux distribution is a member of the family of Unix-like operating systems built on top of the Linux kernel. Such distributions are operating systems including a large collection of software applications such as word processors, spreadsheets, media players, and database applications...

s. The Solaris Operating System
Solaris Operating System
Solaris is a Unix operating system originally developed by Sun Microsystems. It superseded their earlier SunOS in 1993. Oracle Solaris, as it is now known, has been owned by Oracle Corporation since Oracle's acquisition of Sun in January 2010....

 has used GRUB as its boot loader on x86 systems starting with the Solaris 10 1/06 release.

History

GRUB was initially developed by Erich Boleyn as part of work on booting the operating system
Operating system
An operating system is a set of programs that manage computer hardware resources and provide common services for application software. The operating system is the most important type of system software in a computer system...

 GNU Hurd
GNU Hurd
GNU Hurd is a free software Unix-like replacement for the Unix kernel, released under the GNU General Public License. It has been under development since 1990 by the GNU Project of the Free Software Foundation...

 developed by the Free Software Foundation
Free Software Foundation
The Free Software Foundation is a non-profit corporation founded by Richard Stallman on 4 October 1985 to support the free software movement, a copyleft-based movement which aims to promote the universal freedom to create, distribute and modify computer software...

. In 1999, Gordon Matzigkeit and Yoshinori K. Okuji made GRUB an official software package of the GNU Project
GNU Project
The GNU Project is a free software, mass collaboration project, announced on September 27, 1983, by Richard Stallman at MIT. It initiated GNU operating system development in January, 1984...

 and opened the development process
Software development process
A software development process, also known as a software development life cycle , is a structure imposed on the development of a software product. Similar terms include software life cycle and software process. It is often considered a subset of systems development life cycle...

 to the public.

Features

GRUB is dynamically configurable. It loads its configuration at startup, allowing boot-time changes such as selecting different kernels or initial RAM disks
Initrd
In computing, initrd is a scheme for loading a temporary file system into memory in the boot process of the Linux kernel. initrd and initramfs refer to slightly different methods of achieving this...

. 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, VFAT
File Allocation Table
File Allocation Table is a computer file system architecture now widely used on many computer systems and most memory cards, such as those used with digital cameras. FAT file systems are commonly found on floppy disks, flash memory cards, digital cameras, and many other portable devices because of...

 and NTFS used by Windows, as well as Logical Block Address (LBA) mode. GRUB allows users to view the contents of files on any supported file system.

GRUB can be used with a variety of different user interface
User interface
The user interface, in the industrial design field of human–machine interaction, is the space where interaction between humans and machines occurs. The goal of interaction between a human and a machine at the user interface is effective operation and control of the machine, and feedback from the...

s. 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 set to use a serial link
Serial port
In computing, a serial port is a serial communication physical interface through which information transfers in or out one bit at a time...

 to provide a remote terminal boot loader access.

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.

Although Multiboot compliant, GRUB supports non-multiboot operating systems via chain loading
Chain loading
Chain loading is a method used by computer programs to replace the currently executing program with 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...

. GRUB uses the same two or three lines of command sequences to boot any DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

, Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

, Linux
Linux
Linux is a Unix-like computer operating system assembled under the model of free and open source software development and distribution. The defining component of any Linux system is the Linux kernel, an operating system kernel first released October 5, 1991 by Linus Torvalds...

, BSD or Solaris system, making it very easy to work with. The chain loaders
Chain loading
Chain loading is a method used by computer programs to replace the currently executing program with 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...

 for the supported Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...

-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 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
Floppy disk
A floppy disk is a disk storage medium composed of a disk of thin and flexible magnetic storage medium, sealed in a rectangular plastic carrier lined with fabric that removes dust particles...

, USB device or a CD-ROM
CD-ROM
A CD-ROM is a pre-pressed compact disc that contains data accessible to, but not writable by, a computer for data storage and music playback. The 1985 “Yellow Book” standard developed by Sony and Philips adapted the format to hold any form of binary data....

 to boot up an installed operating system.

A GRUB installation for any supported OS can be installed from any of the usual Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....

 operating systems as well as using specific GRUB implementations for DOS
DOS
DOS, short for "Disk Operating System", is an acronym for several closely related operating systems that dominated the IBM PC compatible market between 1981 and 1995, or until about 2000 if one includes the partially DOS-based Microsoft Windows versions 95, 98, and Millennium Edition.Related...

 and Windows
Microsoft Windows
Microsoft Windows is a series of operating systems produced by Microsoft.Microsoft introduced an operating environment named Windows on November 20, 1985 as an add-on to MS-DOS in response to the growing interest in graphical user interfaces . Microsoft Windows came to dominate the world's personal...

.

Boot process

When a computer is turned on, the computer's BIOS
BIOS
In IBM PC compatible computers, the basic input/output system , also known as the System BIOS or ROM BIOS , is a de facto standard defining a firmware interface....

 finds the primary bootable device (usually the computer's hard disk) and loads the initial bootstrap program from the master boot record
Master boot record
A master boot record is a type of boot sector popularized by the IBM Personal Computer. It consists of a sequence of 512 bytes located at the first sector of a data storage device such as a hard disk...

 (MBR), the first 512 bytes of the hard disk, then transfers control to this code.

GRUB version 1

The MBR
Master boot record
A master boot record is a type of boot sector popularized by the IBM Personal Computer. It consists of a sequence of 512 bytes located at the first sector of a data storage device such as a hard disk...

 usually contains GRUB stage 1, but can contain another bootloader which can chain boot
Chain loading
Chain loading is a method used by computer programs to replace the currently executing program with 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...

 GRUB stage 1 from another boot sector
Boot sector
A boot sector or boot block is a region of a hard disk, floppy disk, optical disc, or other data storage device that contains machine code to be loaded into random-access memory by a computer system's built-in firmware...

 such as a partition's Volume boot record
Volume Boot Record
A volume boot record is a type of boot sector introduced by the IBM Personal Computer...

. Given the small size of a boot sector
Boot sector
A boot sector or boot block is a region of a hard disk, floppy disk, optical disc, or other data storage device that contains machine code to be loaded into random-access memory by a computer system's built-in firmware...

, 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's 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
GUID Partition Table
In computer hardware, GUID Partition Table is a standard for the layout of the partition table on a physical hard disk. Although it forms a part of the Extensible Firmware Interface standard , it is also used on some BIOS systems because of the limitations of MBR partition tables, which restrict...

 or LVM
Logical Volume Manager (Linux)
LVM is a logical volume manager for the Linux kernel; it manages disk drives and similar mass-storage devices, in particular large ones. The term "volume" refers to a disk drive or partition thereof...

 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
Master boot record
A master boot record is a type of boot sector popularized by the IBM Personal Computer. It consists of a sequence of 512 bytes located at the first sector of a data storage device such as a hard disk...

 or Volume boot record
Volume Boot Record
A volume boot record is a type of boot sector introduced by the IBM Personal Computer...

 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

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.

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

. 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.

Installation

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 LILO
LILO (boot loader)
LILO is a generic boot loader for Linux.-Overview:LILO does not depend on a specific file system, and can boot an operating system from floppy disks and hard disks. One of up to sixteen different images can be selected at boot time. Various parameters, such as the root device, can be set...

, 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
OpenSUSE
openSUSE is a general purpose operating system built on top of the Linux kernel, developed by the community-supported openSUSE Project and sponsored by SUSE...

 and (for GRUB legacy) in Debian GNU/Linux the file is stored in /boot/grub/menu.lst while Fedora
Fedora (operating system)
Fedora is a RPM-based, general purpose collection of software, including an operating system based on the Linux kernel, developed by the community-supported Fedora Project and sponsored by Red Hat...

, Gentoo Linux
Gentoo Linux
Gentoo Linux is a computer operating system built on top of the Linux kernel and based on the Portage package management system. It is distributed as free and open source software. Unlike a conventional software distribution, the user compiles the source code locally according to their chosen...

, and (for GRUB 2) Debian use /boot/grub/grub.conf or ../grub.cfg. Fedora also provides a symbolic link
Symbolic link
In computing, a symbolic link is a special type of file that contains a reference to another file or directory in the form of an absolute or relative path and that affects pathname resolution. Symbolic links were already present by 1978 in mini-computer operating systems from DEC and Data...

 from /etc/grub.conf to /boot/grub/grub.conf for FHS
Filesystem Hierarchy Standard
The Filesystem Hierarchy Standard defines the main directories and their contents in Linux operating systems. For the most part, it is a formalization and extension of the traditional BSD filesystem hierarchy....

 compatibility reasons.

GRUB can be installed on removable media
Removable media
In computer storage, removable media refers to storage media which is designed to be removed from the computer without powering the computer off.Some types of removable media are designed to be read by removable readers and drives...

 such as an optical drive (bios access, and el-torito
El Torito (CD-ROM standard)
The El Torito Bootable CD Specification is an extension to the ISO 9660 CD-ROM specification. It is designed to allow a computer to boot from a CD-ROM...

), floppy disk
Floppy disk
A floppy disk is a disk storage medium composed of a disk of thin and flexible magnetic storage medium, sealed in a rectangular plastic carrier lined with fabric that removes dust particles...

 or USB flash drive
USB flash drive
A flash drive is a data storage device that consists of flash memory with an integrated Universal Serial Bus interface. flash drives are typically removable and rewritable, and physically much smaller than a floppy disk. Most weigh less than 30 g...

 in order to bring up a system which may not have or cannot boot from a hard disk.

Development

The most commonly used version of GRUB is referred to as "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
Rewrite (programming)
A rewrite in computer programming is the act or result of re-implementing a large portion of existing functionality without re-use of its source code. When the rewrite is not using existing code at all, it is common to speak of a rewrite from scratch...

 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
Platform (computing)
A computing platform includes some sort of hardware architecture and a software framework , where the combination allows software, particularly application software, to run...

, internationalization
Internationalization and localization
In computing, internationalization and localization are means of adapting computer software to different languages, regional differences and technical requirements of a target market...

/localization
Internationalization and localization
In computing, internationalization and localization are means of adapting computer software to different languages, regional differences and technical requirements of a target market...

, non-ASCII characters, dynamic modules, memory management
Memory management
Memory management is the act of managing computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. This is critical to the computer system.Several...

, a scripting mini-language, migrating platform specific (x86) code to platform specific modules, and an object-oriented framework. Ubuntu
Ubuntu (operating system)
Ubuntu is a computer operating system based on the Debian Linux distribution and distributed as free and open source software. It is named after the Southern African philosophy of Ubuntu...

 adopted GRUB 2 as its default boot loader on its 9.10 version.

Variants

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
Fork (software development)
In software engineering, a project fork happens when developers take a legal copy of source code from one software package and start independent development on it, creating a distinct piece of software...

) 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 builtin BIOS disk emulation, ATAPI CDROM driver, etc. It has enhanced several commands, including "find --set-root", "map --hook", and "cdrom").

OpenSolaris
OpenSolaris
OpenSolaris was an open source computer operating system based on Solaris created by Sun Microsystems. It was also the name of the project initiated by Sun to build a developer and user community around the software...

 includes a modified GRUB Legacy which supports disklabels, automatic 64-bit kernel selection, and booting from ZFS
ZFS
In computing, ZFS is a combined file system and logical volume manager designed by Sun Microsystems. The features of ZFS include data integrity verification against data corruption modes , support for high storage capacities, integration of the concepts of filesystem and volume management,...

 (with compression
Data compression
In computer science and information theory, data compression, source coding or bit-rate reduction is the process of encoding information using fewer bits than the original representation would use....

 and multiple boot environments).
Syllable OS project made a modified version of GRUB to load the system from its AtheOS File System
AtheOS File System
The AtheOS file system was originally used in the AtheOS operating system, and is now a part of the Syllable operating system. AFS started with exactly the same data structures as the Be File System, BFS, and extended its feature set in many ways. As such, AFS is a 64-bit journaled file system...

.

GRUB configuration tools

The setup tools in use by various distributions often include modules to set up GRUB: for example, so do YaST2 on SUSE
SUSE Linux distributions
SUSE Linux is a computer operating system. It is built on top of the open source Linux kernel and is distributed with system and application software from other open source projects. SUSE Linux is of German origin and mainly developed in Europe. The first version appeared in early 1994, making...

/openSUSE
OpenSUSE
openSUSE is a general purpose operating system built on top of the Linux kernel, developed by the community-supported openSUSE Project and sponsored by SUSE...

 distributions and Anaconda on Fedora
Fedora (operating system)
Fedora is a RPM-based, general purpose collection of software, including an operating system based on the Linux kernel, developed by the community-supported Fedora Project and sponsored by Red Hat...

/RHEL
Red Hat Enterprise Linux
Red Hat Enterprise Linux is a Linux-based operating system developed by Red Hat and targeted toward the commercial market. Red Hat Enterprise Linux is released in server versions for x86, x86-64, Itanium, PowerPC and IBM System z, and desktop versions for x86 and x86-64...

 distributions. StartUp-Manager
StartUp-Manager
StartUp-Manager was a program to configure GRUB, GRUB2, Usplash and Splashy. It was originally an Ubuntu project, but was later adapted to Debian....

 is a graphical configuration editor for Debian
Debian
Debian is a computer operating system composed of software packages released as free and open source software primarily under the GNU General Public License along with other free software licenses. Debian GNU/Linux, which includes the GNU OS tools and Linux kernel, is a popular and influential...

 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.

Utilities

GRUB Utilities is a collection of multi-platform utilities for GRUB Legacy, GRUB2 and GRUB for DOS.

See also

  • Comparison of boot loaders
    Comparison of boot loaders
    The following tables compare general and technical information for a number of available boot loaders.-Features:- External links :* * Let you boot legacy PCs from CD-ROM and USB without BIOS support...

  • NTLDR
    NTLDR
    NTLDR is the boot loader for all releases of Windows NT operating system up to and including Windows XP and Windows Server 2003. NTLDR is typically run from the primary hard disk drive, but it can also run from portable storage devices such as a CD-ROM, USB flash drive, or floppy disk...


External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK