As more enterprise Linux servers adopt the GRUB2 bootloader, you'll need to be ready to work with -- and troubleshoot...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
-- GRUB2-based systems.
GRUB2 is appearing on more and more Linux systems as the default bootloader. The last release of every major Linux distribution uses it, so it's only a matter of time before GRUB2 becomes the default bootloader on enterprise Linux distributions such as SUSE Linux Enterprise Server and Red Hat Enterprise Linux.
In GRUB2, almost everything is different. Where the old GRUB bootloader version had a master configuration file /boot/grub/grub.conf, administrators cannot edit the GRUB2 configuration file /boot/grub2/grub.cfg. Instead, you'll work with input files in the directory /etc/grub.d/ along with the configuration file /etc/defaults/grub. After changing these files, you'll update GRUB2 via the grub2-mkconfig command, which writes the information to the appropriate locations in the metadata area at the beginning of your computer's hard drive.
Some things haven't changed from earlier versions; GRUB2 still points to a kernel file and an initrd, which are still needed to boot your server.
When something goes wrong with the GRUB2 configuration, there are a few troubleshooting options. If your server doesn't boot anymore, you still can access a boot prompt. If your distribution doesn't show a menu while booting, you can enter the GRUB2 boot prompt by pressing the Escape key. When you select the enter mode on the kernel, it shows a boot menu (Listing 1).
Listing 1. This OpenSUSE boot menu is one example of how you can troubleshoot problems with the GRUB2 bootloader.
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' a55761c2-7e1c-45b6-9400-e662314d5c96
search --no-floppy --fs-uuid --set-root a55761c2-7e1c-45b6-9400-e662314d5c96
echo 'Loading Linux 3.4.6-2.10-desktop ...
linux /vmlinuz-3.4.6-2.10-desktop root=/dev/mapper/vgsys-root video=1366x768 resume=/dev/vgsys/swap splash=silent quiet showopts
echo 'Loading initial ramdisk ...'
The most important difference between GRUB and GRUB2 is how GRUB2 indicates the root device. GRUB2 is designed to be flexible because it has to deal with the old BIOS way of booting a computer as well as the new UEFI method of booting a server. This creates a lot of options.
To start with, the line set root='hd0,msdos1' in Listing 1 identifies the boot device as the first hard disk (hd) and, on that hard disk, the second partition is identified as msdos1. This has nothing to do with the legacy Microsoft MS-DOS operating system, but is all about disk compatibility. A disk that uses a master boot record (MBR) is known as an msdos disk type; msdos1 means that GRUB2 has to look inside the partition table of this disk to identify the second partition.
When no MBR system is used, the piece of shell code inside the GRUB2 bootloader makes sure all possible options are considered and GRUB2 figures out which type is in use.
GRUB2 also changes how you work with modules. Modules are referred to from the first lines of the GRUB2 configuration using the insmod command. The GRUB2 bootloader uses file system support modules as well as hardware support modules. The /boot/grub2/i386-pc directory lists all modules available. Many new items are supported, including new Linux file systems such as btrfs or even ZFS, and disk layout features such as LVM and LUKS encrypted devices. And, of course, it supports the new UEFI-based (Unified Extensible Firmware Interface) disk layout.
From the GRUB boot shell, you can modify any parameter, then press F10 to boot your system. Remember to apply the changes persistently to your server once it has booted completely by modifying the /etc/default/grub file or the appropriate configuration files in /etc/grub.d.
If the GRUB2 configuration becomes damaged in a way that doesn't allow you to boot into the GRUB shell, use a rescue disk, preferably the one that came with your OS. If necessary, use a generic rescue disk, such as Knoppix. Once booted from the rescue disk, you can execute the grub2-install command to reinstall the GRUB2 boot image to the metadata area of your hard disk.
About the author:
Sander van Vugt is an independent trainer and consultant based in the Netherlands. He is an expert in Linux high availability, virtualization and performance. He has authored many books on Linux topics, including Beginning the Linux Command Line, Beginning Ubuntu LTS Server Administration and Pro Ubuntu Server Administration.