Grub version 1
NOTE: This is a description of what is now (2011) being referred to as "legacy" GRUB. It has been taken over by the GNU Project, but is no longer under development. For a modern version, see GNU GRUB.
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.
- Grub-0.97 is compatible with LDM and can boot firmware raid compatible with dmraid, including raid-0
- 1 GRUB boot menu
- 2 Installing the GRUB bootloader
- 3 Errors and solutions
- 3.1 Error 18
- 3.2 Error 21
- 3.3 GRUB - nothing else
- 3.4 Invalid or damaged bootable partition
- 4 Tips
- 5 See also
- 6 External links
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.
To configure grub, find out your distribution. SUSE uses /boot/grub/menu.lst, Red Hat and Ubuntu use /boot/grub/grub.cfg. Full documentation of the format of the 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 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 also manages the menu.lst file itself. It should be updated automatically when a kernel rpm is installed or removed
title Win rootnoverify (hd0,0) makeactive chainloader +1
If you where to have dual-booting with Linux on the first disk and Windows on the 2nd or some other disk you will run into a common trouble: WARNING 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 to correct this problem would look like:
title Win rootnoverify (hd1,0) map (hd0) (hd1) map (hd1) (hd0) makeactive chainloader +1
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/
Removing obsolete kernels
To remove obsolete kernel entries from your boot menu, it is enough to uninstall the old kernels like this:
rpm -e kernel-default-22.214.171.124-0.2
Installing the GRUB bootloader
There are some cases when you want to install a bootloader to your disk:
To install a GRUB bootloader to your harddisk (we take /dev/sda as an example here), issue
GRUB will be installed then and use the file /boot/grub/menu.lst as boot menu.
Errors and solutions
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.
Error 18 on Dual Boot Systems Using a Single Hard Drive
This error often occurs when creating a dual boot system (with Windows) on a single hard disk drive, as in a notebook PC, because the Linux partitions end up being beyond the LBA range. On a large notebook drive you may need to re-install Windows into a smaller primary partition (or resize the partition), then create an extended partition in the unallocated space and create partitions for Linux Root, Linux Swap, and Linux Home, then in the remaining unallocated space create another NTFS partition for Windows. In other words, the Linux partitions must be immediately after the Primary Windows partition so they are still within the LBA range, then you can place additional NTFS or FAT32 partitions after the Linux partitions.
On a 160GB notebook drive, the following gave Error 18:
Primary: 80GB Windows NTFS
Extended: 4GB (FAT32), 50GB (NTFS), 4GB Linux Root (ext3), 2GB Linux Swap, 20GB Linux home (ext3).
The following worked:
Primary: 80GB Windows NTFS
Extended: 4GB Linux Root (ext3), 2GB Linux Swap, 20GB Linux home (ext3), 4GB (FAT32), 50GB (NTFS).
It can be somewhat of an annoyance to have the NTFS file system split into two partitions, but it's a workaround.
[Note: the reason for the 4GB FAT 32 partition is that it makes it possible for both Windows and Linux to access that partition, which can be useful when transferring files between the two operating systems.]
Removing GRUB After Error 18 on a Dual Boot System (Windows/Linux) Using a Single Hard Drive
If you install GRUB on a dual boot system with a single hard drive, and get Error 18, you will not be able to boot Windows. To fix this, you need to boot the system from a Windows Recovery CD, select "R" for Repair, and then run "fixmbr" (fix master boot record) at the DOS prompt in C:\windows. This will remove GRUB. If you don't have a recovery CD, you can download floppies from Microsoft for XP, see "http://support.microsoft.com/kb/310994".
Error 21: Unknown boot failure
When booting, you get line saying
then the system stops.
This error can have at least one reason: an incorrect device list handed over to grub's setup command.
To resolve this error, use grub-install and watch its output thoroughly:
tweedleburg:~ # grub-install /dev/sda GNU GRUB version 0.97 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ] grub> setup --stage2=/boot/grub/stage2 (hd0,0) (hd0,0) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd0,0)"... failed (this is not fatal) Running "embed /boot/grub/e2fs_stage1_5 (hd0,0)"... failed (this is not fatal) Running "install --stage2=/boot/grub/stage2 /boot/grub/stage1 (hd0,0) /boot/grub/stage2 p/boot/grub/menu.lst "... succeeded Done. grub> quit tweedleburg:~ #
Now watch the highlighted line. If you run into grub error 21, check that there are no non-existant devices. If there are, you may have found the issue. In this case, call
and issue the correct setup command in its shell.
Your bootloader tries to load /boot/grub/menu.lst from a hard disk that no longer exists. For example, this can happen if you installed Linux for booting from USB, you removed the USB disk, and the MBR has been changed.
Re-attach the missing disk, re-run grub-install.
Your initrd is broken. Call grub and test it like this:
GNU GRUB version 0.97 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ] grub> root (hd0,0) Filesystem type is ext2fs, partition type 0x83 grub> kernel /boot/vmlinuz [Linux-bzImage, setup=0x3000, size=0x1ffb98] grub> initrd /boot/initrd Error 16: Inconsistent filesystem structure grub>
GRUB - nothing else
- When booting from USB, you get a line saying
- This can be a problem with your device map. Keep in mind that, when booting from USB, your USB disk corresponds to (hd0), the first harddisk. grub-install will tell you where its device map is - try correcting it.
Invalid or damaged bootable partition
When booting, you do not get a grub menu, but a message saying
Invalid or damaged Bootable partition
The reason can be that you installed grub to a partition that no longer exists. For example, you installed onto a disk that was the third in the device order and now another disk has been removed and grub can no longer access the "third" disk. You must know that the first disk is called hd(0), the second hd(1) and the third hd(2). When trying to re-install grub, you would see
tweedleburg:/boot/grub> grub-install --recheck /dev/sdc GNU GRUB version 0.97 (640K lower / 3072K upper memory) [ Minimal BASH-like line editing is supported. For the first word, TAB lists possible command completions. Anywhere else TAB lists the possible completions of a device/filename. ] grub> setup --stage2=/boot/grub/stage2 --force-lba (hd0) (hd2,0) Error 21: Selected disk does not exist grub> quit tweedleburg:/boot/grub>
Where (hd2) does not exist. In /etc/grub.conf you find
setup --stage2=/boot/grub/stage2 (hd0,0) (hd2,0)
- GNU GRUB
- Securing GRUB
- GRUB Floppies to boot large kernels
- Booting from USB - includes troubleshooting procedures
- Original legacy project website (www.oruk.org)
- GNU GRUB Project website (www.gnu.org)
- GRUB Manual (www.gnu.org)
- Grub error codes list
- Linux+Win+Grub HowTo (tldp.org)