5/01/2013

GRUB 2 Bootloader

While GRUB Legacy received it's last update in 2005 to 0.97, it will probably be around for several more years. Meanwhile, GRUB 2 has begun to replace GRUB in progressive distributions like Ubuntu and Fedora. The new GRUB, GRand Unified Bootloader, offers several advantages:
  • Dynamically loaded modules
  • Non-ASCII character support
  • Ability to boot from partitions inside of Logical Volume Management (LVM) or RAID
  • Ability to work with many architectures without a PC BIOS
As in previous posts, what I will describe pertains to Fedora. Notably, Fedora uses /boot/grub2/grub.cfg instead of /boot/grub/grub.cfg that I've seen mentioned for Ubuntu-based distributions.
Previously, GRUB stored it's components under /boot/grub and was primarily configured with either /boot/grub/menu.lst or /boot/grub/grub.conf.

Now, GRUB 2 uses several locations for it's files:
  • /boot/grub2
    • Contains many module files
    • grub.cfg which should not be edited manually
    • grubenv another configuration file which should not be edited
  • /etc/default/grub
    • contains the entries for creating a default boot entry
    • typically where customization will be done
  • /etc/grub.d directory
    • contains scripts that are run by grub2
    • scripts can be customized or added
    • Contains the following executable scripts: 
      • /etc/grub.d/00_header
      • /etc/grub.d/10_linux
      • /etc/grub.d/20_linux_xen
      • /etc/grub.d/30_os-prober
      • /etc/grub.d/40_custom
      • /etc/grub.d/41_custom
      • /etc/grub.d/90_persistent
  • /usr/lib/grub/directory
    • Stores a couple of library files
  • /sbin/grub2-mkconfig
    • Used to regenerate the /boot/grub2/grub.cfg
Here's what the /etc/default/grub looks like in Fedora 16:
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
# GRUB_TERMINAL="serial console"
# GRUB_SERIAL_COMMAND="serial --unit=0 --speed=9600"
GRUB_CMDLINE_LINUX="quiet rhgb"
GRUB_DISABLE_RECOVERY="true"


There are just a few of entries in this file that might need customization:
The GRUB_TIMEOUT is how many seconds before the default is booted. Some people might like more time than this, particularly if dual booting operating systems.

The GRUB_CMDLINE_LINUX contains the parameters that are passed to the Linux kernel. Occasionally, some systems might require additional parameters be passed, so this might also be customized.

Also, the GRUB_TERMINAL and GRUB_SERIAL_COMMAND might be uncommented to provide a serial console.

After updating don't forget to execute:
/sbin/grub2-mkconfig




No comments:

About Me - WrightRocket

My photo

I've worked with computers for over 30 years, programming, administering, using and building them from scratch.

I'm an instructor for technical computer courses, an editor and developer of training manuals, and an Android developer.