View the Most Wanted LQ Wiki articles.
LinuxQuestions.org > Linux Wiki > GRUB

From LQWiki

(Redirected from GRUB boot menu)
Jump to: navigation, search

GRUB (short for GRand Unified Boot Loader) is a boot loader, similar in overall function to LILO. It is the standard way to boot into an operating system (or several) used by most recent Linux distributions, but capable of being loaded on any Linux distro.

GRUB may have advantages over your current bootloader, but it's your choice.

  • You can change your boot menu entries by editing a text file. While LILO requires the text file to be amended and the need to re-run /sbin/lilo.
  • You can "test" your boot menu entries in an interpreted environment. This may prevent some minor changes that renders the system unbootable.
  • Grub boot floppies can use a kernel size of 1423 Kb and an initrd of 1423 Kb using 3 floppies to boot.

Contents

GRUB boot menu

The default location is in /boot/grub/menu.lst. The .lst suffix stands for menu list, not menu first. The file contains configuration options (like default boot entry, (grub.enbug.org) color, timeout and password settings) and a list of menu entries. The file is often managed by some tool from the distribution itself, so when kernels are installed or removed the boot menu list gets automatically updated. Another common location is /etc/grub.conf but this is often a link file to the /boot/grub file.

Manual configuration

Full documentation of the format of the menu.lst file can be found in the GRUB info pages. But for a quick start, here are a couple of example entries to get you going.

Basic entry to boot a linux kernel located on the first disk:

title Linux kernel 2.6.4 
      root (hd0,0) 
      kernel /boot/vmlinuz-2.6.4 root=/dev/hda1 ro 3
      initrd /boot/initrd.img 
  • title denotes the selectable boot-menu title;
  • root (hd0,0) says /boot partition is on the first partition first drive or that the SUB-folder /boot to the / partition refers to same structure;
  • kernel tells grub where to find the linux kernel. The "root" mentioned after vmlinuz refers to the / entry in your /etc/fstab file. Kernel parameters such as desired runlevel (3) may be presented at the end of the kernel-line;
  • initrd describes the use and location of a preconfigured ramdisk.

Note that grub starts counting disks from 0, while skipping other IDE devices. Thus /dev/hda1=(hd0,0) and /dev/hdc1=(hd1,0) when a cdrom-drive is attached as slave on the first IDE-channel. When adding drives to an existing configuration, drives.map may need to be refreshed from within grub, especially when more than one drive/partition is bootable.

Debian

Debian manages the menu file with update-grub. This script checks which kernels are located in /boot/ and generates a menu entry for them. It adds its own configuration options to the menu.lst file. These concern the options that are given to the generated menu entries. Usually, update-grub is automatically run after kernel packages have been installed or removed (at least it's the default configuration for the sarge/testing disribution). If not, update-grub can be added as a postinst_hook and a postrm_hook in the /etc/kernel-img.conf file.

Red Hat

Red Hat also manages the menu.lst file itself. It should be updated automatically when a kernel rpm is installed or removed

SuSE

SuSE manages the menu.lst of GRUB using YAST.

Booting Windows/DOS

title Win 
rootnoverify (hd0,0) 
makeactive 
chainloader +1 

Whenever you'd want to have dual-booting with Linux to be on the first disk and Windows on some other one you'll run into common trouble: Windows only wants to boot from partitions on first disk in the system. But GRUB can trick Windows with the map command, an example entry would look like:

title Win
rootnoverify (hd1,0)
map (hd0) (hd1)
map (hd1) (hd0)
makeactive
chainloader +1

Shutdown the machine from the menu

Another menu entry that can be handy is one to shutdown the machine:

title Halt!
halt

Using a Splash Image

You can make grub display a nice looking splash image at the menu screen. See http://ruslug.rutgers.edu/~mcgrof/grub-images/

Errors and solutions

Error 18

Error 18: Selected cylinder exceeds maximum supported by BIOS
This error is returned when a read is attempted at a linear block address beyond the end of the BIOS translated area. This generally happens if your disk is larger than the BIOS can handle (512MB for (E)IDE disks on older machines or larger than 8GB on others.). In more practical terms this means the BIOS is unable to start executing the kernel because the kernel is not located within the block it can access at boot up time.

This can be circumvented by creating a boot partition at the beginning of the disk that is completely within the first 1023 cylinders of the harddrive. This partition will contain the kernel.

The kernel itself does not suffer from the same limitations as the BIOS so after the BIOS has loaded the kernel the kernel will have no problem accessing the whole harddrive. Newer BIOSes will automatically translate the harddrives size in a way that it can be completely contained within the first 1023 cylinders and hence modern computers do not suffer from this problem.
The same error can happen when the BIOS detects a disk in a different way as Linux does. This can happen when changing motherboards or when moving a GRUB-bootable disk from one computer to another. If this happens, just boot with a GRUB floppy, read the C/H/S numbers from the existing partition table and manually edit the BIOS numbers to match. If using a SUSE linux and installing on VM Ware this problem is solved by creating a small partition at the very beginning of the harddisc, and mounting it as /boot.

Tips

For an awesome resource for troubleshooting just about any Grub problem (on any OS), see this thread on Gentoo's forums: Gentoo Forums: Grub Error Collection

See also

External links


Personal tools