Using GRUB 2

Slashdot it! Delicious Share on Facebook Tweet! Digg!

Next Generation

,

GRUB 2 is more than just a system for booting from a disk. In this article, we'll provide an overview of the capabilities of the newest version of GRUB, GRUB 2.

At one time, the first operating system on a hard drive was the only one. Today, users expect more. Not only should different systems run in parallel on a computer, but you should expect various boot media and individual configurations. Current Linux systems depend on GRUB 2 and its flexibility. With GRUB 2, you can customize the boot process, secure a system against unauthorized access, and make mobile devices distinct.

What is GRUB 2?

GRUB stands for GRand Unified Bootloader [1]. The program helps the user select an operating system from a memory device – be it hard disk, CD/DVD, USB stick, or SD card – and starts it up. On startup, GRUB first reads from the storage medium the boot information in the Master Boot Record (MBR; or in ROM in mobile devices). After a short welcome screen, GRUB displays a selection menu for your operating system then gives control to the (Linux) kernel of the system you select.

GRUB has been in version 2 since June 2012 – the pre-release since Ubuntu 9.10 appeared as version 1.98/1.99. Although you can theoretically continue to use GRUB 1 (0.97), which is now officially called GRUB Legacy, GRUB 2 was completely rewritten and is not backward compatible because the bootloader is not supposed to carry any old baggage around with it.

What Can GRUB 2 Do?

GRUB 2 is extremely flexible and supports booting partitions with the ISO 9660 (CD/DVD), NTFS, Ext2/3/4, ZFS, and Btrfs filesystems. It can also handle Logical Volume Managers (LVMs) and software/hardware RAID. The Linux kernel provided over the network (TFTP) can be integrated into the selection menu (PXE boot). GRUB 2 differentiates hard drives with Universally Unique Identifiers (see the "UUID" box) with the use of labels as well as shell-like scripts that handle entries in the boot menu.

UUID

Simply put, a Universally Unique Identifier (per RFC 4122 [2]) is a standardized sequence of characters that, among other things, identifies hard drives and partitions, including RAID systems and the Logical Volume Manager (LVM). It consists of a 16-byte hexadecimal number in five groupings. For example, the /etc/fstab file uses this to mount single partitions at the right location (Listing 1). Moreover, UUIDs ensure that hard drives get the same mount points after every boot. With the earlier notation, (e.g., /dev/sda1 and /dev/sda6 , commented out in the listing), the mount points were somewhat less defined.

Listing 1

/etc/fstab

# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# /dev/sda1     /boot            ext3    defaults         0       2
UUID=0127f1e9-6401-44c0-ab71-1515795a473b       /boot           ext3 defaults        0       2
# /dev/sda6     /home            ext3    defaults         0       2
UUID=dddcee4d-69c3-401e-8c20-28ec531ebe60       /home           ext3 defaults,user_xattr        0       2

Among the highlights of GRUB 2 is that it loads individual components as modules at run time. Entries in the boot menu are easier to handle in this way than with its predecessor and occur through the central configuration file /etc/default/grub , which not only allows the use of a background image but also integrates a recovery environment. If something goes wrong at boot time, you can go into recovery mode and fix the problem.

Unlike its predecessor, GRUB 2 doesn't show the boot menu if there's only one resident operating system. To make the boot menu appear, you have to change the bootloader configuration. Open a terminal with Ctrl+Alt+T and open the configuration file in an editor:

$ gksu gedit /etc/default/grub

In the file, comment out the entry GRUB_HIDDEN_TIMEOUT=0 and set GRUB_TIMEOUT=10 to show the bootmenu for 10 seconds before Ubuntu uses the topmost system listed (Figure 1). Use the following command to make your changes:

Figure 1: If only one system resides on the hard drive, GRUB 2 no longer shows the boot menu, although you can change that behavior with a configuration setting.
$ sudo update-grub

The boot menu now shows up at each reboot.

Buy this article as PDF

Express-Checkout as PDF

Pages: 4

Price $0.99
(incl. VAT)

Buy Ubuntu User

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Encrypted ZFS with Ubuntu

    ZFS is one of the most advanced filesystems, and now it can be used natively on Linux. One drawback is that native ZFS encryption is not available, but this article shows how use Linux's disk encryption to install Ubuntu onto an encrypted disk with ZFS.

  • Installing Ubuntu 13.10

    Ubuntu 13.10 offers some changes to the installation process. We'll walk you through upgrading or installing the latest release.

  • Installing Ubuntu 13.10

    Ubuntu 13.10 offers some changes to the installation process. We'll walk you through upgrading or installing the latest release.

  • Installing Ubuntu 14.04

    Ubuntu 14.04 offers some changes to the installation process. We'll walk you through upgrading or installing the latest release.

  • Installing Ubuntu 12.10

    Ubuntu 12.10 offers a few changes to the installation process. We'll walk you through upgrading or installing the latest release.