GNU GRUB

GNU GRUB

GRUB in text mode
Developer(s) GNU Project
Stable release 1.99 (GRUB2)[1] / May 15, 2011; 8 months ago (2011-05-15)
Development status Active
Written in Assembly, C[2]
Operating system Linux, Mac OS, Solaris and Windows
Platform IA-32, x86-64, PowerPC
Available in English and others
Type Bootloader
License GNU GPL 3+[2]
Website www.gnu.org/software/grub/

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[3]). 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.

Contents

History

GRUB was initially developed by Erich Boleyn as part of work on booting the operating system GNU Hurd developed by the Free Software Foundation.[4] 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.[4]

Features

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, VFAT 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 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 set to use a serial link 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. 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 with which to work. 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.

Boot process

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

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.

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, 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 /boot/grub/grub.conf or ../grub.cfg. Fedora also provides a symbolic link from /etc/grub.conf to /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 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,[6] 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.[7]

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) 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.[8] It has enhanced several commands, including "find --set-root", "map --hook", and "cdrom").[9]

OpenSolaris includes a modified GRUB Legacy which supports disklabels, automatic 64-bit kernel selection, and booting from ZFS (with compression and multiple boot environments).[10][11] Syllable OS project made a modified version of GRUB to load the system from its AtheOS File System.[12]

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/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 [13] [14]. 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.[15]

See also

Free software portal
Computer Science portal

Notes

References

  1. ^ http://lists.gnu.org/archive/html/grub-devel/2011-05/msg00032.html
  2. ^ a b "Ohloh Analysis Summary - GNU GRUB". Ohloh. http://www.ohloh.net/p/grub. Retrieved 2010-05-12. 
  3. ^ EnterpriseLinux.com Definitions Definition of GRand Unified Bootloader
  4. ^ a b GRUB Manual - 1.2 Grub History
  5. ^ https://wiki.archlinux.org/index.php/Kernel_modules
  6. ^ GNU GRUB - GRUB 2. Hosted on wayback machine.
  7. ^ GRUB 2 by default, Ubuntu 9.10 Technical Overview, Ubuntu
  8. ^ "Official GRUB4DOS Website". https://gna.org/projects/grub4dos. Retrieved 2009-04-15. 
  9. ^ grub4dos: trunk/README_GRUB4DOS.txt. Retrieved 2010-02-19.
  10. ^ x86: Modifying Boot Behavior by Editing the GRUB Menu at Boot Time, Modifying Solaris Boot Behavior on x86 Based Systems (Task Map) - System Administration Guide: Basic Administration
  11. ^ x86: Supported GRUB Implementations, (System Administration Guide: Basic Administration) - Sun Microsystems
  12. ^ 2.3 Why does Syllable have its own version of GRUB?, Syllable Documentation , Syllable
  13. ^ GRUB2 Bootloader Editor
  14. ^ Grub2 KCM Retrieved 2011-01-27
  15. ^ GRUB Utilities - Summary

External links