Search My Blog

Monday, October 17, 2011

GNU GRUB Boot loader both grub v1 and v2

Translation(s): English - Français - Italiano - Русский

BootLoader > GRUB

GRUB is the GRand Unified Bootloader, a very powerful newish BootLoader that can be used to boot most operating system on the intel platforms.

Debian provides both grub v1 and v2 (more on Debian BootLoader).

Installing Grub

Up to Debian Lenny

Grub v1 for Debian (package grub) can be installed with:

  • apt-get install grub

To install grub v2, you need install the appropriate variant of grub v2, depending on your system's firmware (usually grub-pc, see grub2 variants).

See Also

Debian Squeeze and later

Grub "v2" for Debian (package grub) can be installed with:

  • apt-get install grub

If your system isn't a regular PC (i.e if your system has EFI or OpenFirmware rather than a BIOS), you may have to install another version of grub (see grub 2 variants).

Configuring Grub

Configuring grub v1

The configuration file is /boot/grub/menu.lst

Under Debian, the grub configuration file is updated automatically, when you install a new kernel. This is done automatically by update-grub.

You can edit the settings in /boot/grub/menu.lst. Make sure you read the comments, /usr/share/doc/grub/README.Debian.gz for more information and the update-grub(8) manpage from your distribution.

Configuring grub v2

The configuration file is /boot/grub/grub.cfg, but you shouldn't edit it directly. This file is generated by grub v2's update-grub(8), based on:

  1. The script snippets in /etc/grub.d/

  2. The configuration file /etc/default/grub

To configure grub "v2", you should edit /etc/default/grub, then run update-grub. Advanced configuration are achieved by modifying the snippets in /etc/grub.d/.

Upgrading from v1 to v2

To upgrade to grub v2, you should:

  1. Install grub v2 (but don't remove the grub 1 yet).
  2. Follow the instruction displayed the package installation (i.e grub v1 now has an entry to cascade to grub v2, so reboot and try it, then you can actually enable grub2 bootloader by running upgrade-from-grub-legacy).

Transition from v1 to v2


Dual Boot

Will GRUB allow me to hibernate Linux and activate another operating system (such as Windows XP) that I hibernated earlier, i.e. a !DualHibernate rather than a DualBoot?

Nothing will prevent you to hibernating (GRUB isn't aware that your host is suspended). However, make sure you don't mount the same partition (RW) under any two suspended OS !

Is there a way to install GRUB in the MasterBootRecord from DOS or Windows XP, i.e. a utility similar to rawrite.exe or fdisk.exe that write a GRUB MBR? What I want here is to install Linux without having a bootable floppy

There is/was a win32 Version of GRUB, i used it to install linux from Windows 2000 , but i am not sure what exactly the source is (google for grubwin32) Just unzip grubwin32 to c:\ then run c:\boot\grub\w32grub This would patch the necessary files(under XP, not linux). Then add :

  • to c:\boot.ini

And you now have a grub boot loader on your XP system.

When I upgraded from grub to grub2 I lost an entry to XP/WP7 , how can I recover the menu entry to boot there?
You have to install os-prober, make sure its enabled in grub2 configuration and sync grub2.

apt-get install os-prober
  • Then edit /etc/default/grub and make sure you have a line like


Finally run update-grub2

By default grub2 in debian will not add 'resume=/dev/swap-partition' option.
But if you want to perform this by default you can edit /etc/grub.d/10_linux file and make some changes there:


linux  ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args}

with this

linux  ${rel_dirname}/${basename} root=${linux_root_device_thisversion} ro ${args} resume=`swapon -s | grep '/dev/sd.[0-9]' -o`

This will add your first swap partition to all found linux entries.

See Also


  1. Grub is the main default bootloader on x86... But some other bootloaders are installed by default in some scenario that aren't supported by Grub v1. (1)

Go there...


From Wikipedia, the free encyclopedia

GRUB in text mode
Developer(s) GNU Project
Stable release 1.99 (GRUB2)[1] / May 15, 2011; 4 months ago
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]

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.



[edit] 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]

[edit] 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 to three lines of command sequences to boot any DOS, Windows, Linux, BSD or Solaris system, making it very easy to work with. 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 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.

[edit] 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.

[edit] 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. Stage 1.5 can contain any drivers needed and so easily loads Stage 2. Stage 2 will then load the default configuration file and any other modules needed.

[edit] 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.

[edit] 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. This is the method used to load operating systems such as Windows, that do not support the Multiboot standard. 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.

[edit] 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 uses /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.

[edit] 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,[5] 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.[6]

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

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

[edit] 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 [12] [13]. GRLDR ICE is a tiny tool for modifying the default configuration of grldr file for GRUB4DOS.

[edit] Utilities

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

[edit] See also

[edit] Notes

[edit] References

  1. ^
  2. ^ a b "Ohloh Analysis Summary - GNU GRUB". Ohloh. Retrieved 2010-05-12.
  3. ^ Definitions Definition of GRand Unified Bootloader
  4. ^ a b GRUB Manual - 1.2 Grub History
  5. ^ GNU GRUB - GRUB 2. Hosted on wayback machine.
  6. ^ GRUB 2 by default, Ubuntu 9.10 Technical Overview, Ubuntu[dead link]
  7. ^ "Official GRUB4DOS Website". Retrieved 2009-04-15.
  8. ^ grub4dos: trunk/README_GRUB4DOS.txt. Retrieved 2010-02-19.
  9. ^ 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
  10. ^ x86: Supported GRUB Implementations, (System Administration Guide: Basic Administration) - Sun Microsystems
  11. ^ 2.3 Why does Syllable have its own version of GRUB?, Syllable Documentation , Syllable
  12. ^ GRUB2 Bootloader Editor
  13. ^ Grub2 KCM Retrieved 2011-01-27
  14. ^ GRUB Utilities - Summary

[edit] External links

Go there...

Grub - Boot gru2 from grub1
boot gru2 from grub1 - Google Search
GNU GRUB - Wikipedia, the free encyclopedia
Grub - Debian Wiki
boot - Entry for Grub1 on sda3 into the main Grub2 on sda - Ask Ubuntu - Stack Exchange
Anaconda (installer) - Wikipedia, the free encyclopedia
Modifying Solaris Boot Behavior on x86 Based Systems (Task Map) - System Administration Guide: Basic Administration
GRUB2 Bootloader Editor
Booting linux on x86 with grub2

No comments: