Tip

A new troubleshooting and management process with GRUB2 bootloader

As more enterprise Linux servers adopt the GRUB2 bootloader, you'll need to be ready to work with -- and troubleshoot -- GRUB2-based systems.

GRUB2 is appearing on more and more Linux systems as the default bootloader. The

    Requires Free Membership to View

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.

Troubleshooting routes

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.

setparams 'openSUSE'

 

    load_video

    set gfxpayload=keep

    isnmod gzio

    insmod part_msdos

    insmod ext2

    set root='hd0,msdos1'

    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

    else

      search --no-floppy --fs-uuid --set-root a55761c2-7e1c-45b6-9400-e662314d5c96

    fi

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

    initrd /initrd-3.4.6-2.10-desktop

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.

GRUB2 roots

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.

More Linux boot problems

Fixing a broken initrd

Troubleshooting the init

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 LineBeginning Ubuntu LTS Server Administration and Pro Ubuntu Server Administration.

mail@sandervanvugt.nl

This was first published in August 2013

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.