Customize GRUB2 in Ubuntu

By | September 28, 2014
Don't be shellfish...Share on Google+Share on FacebookTweet about this on TwitterPin on PinterestShare on StumbleUponEmail this to someone

Grub_logo2

GNU GRUB is a bootloader, capable of loading various operating systems when the system starts up. GRUB stands for GRand Unified Bootloader. It is the successor to LILO (LInux LOader), the original bootloader for Linux-based proprietary Operating Systems. GRUB has the following advantages over LILO:

  • GRUB support unlimited no of boot selections, while LILO supports only 16.
  • Unlike LILO, GRUB supports booting over a network.
  • LILO does not have an interactive command interface like GRUB.

Well, before we begin with this tutorial lets understand how GRUB actually works.

When you switch on a computer, the first thing that occurs is a POST, commonly known as Power On Self Test. This basically checks the computer for various devices that are connected to the computer and subsequently the BIOS comes into further action. The BIOS then transfers the control to the boot device, which can be any BIOS-recognized device.

The first sector stored on a hard disk is called Master Boot Record (MBR), which is usually 512 bytes long and contains a very small piece of code called primary boot loader and partition table describing the various partitions on the disk.

The MBR then loads the active partition and loads it into the memory and passes the control to it.

GRUB works in 3 stages

Stage 1: It is located in the MBR and mainly points to the second stage, however it normally loads up the Stage 1.5.

Stage 1.5: It contains the file system drivers, which allows it to load Stage 2 directly from any known location.

Stage 2: Loads the configuration file that contains all of the user interface and options that are displayed on the screen.

The advantage of this Stage architecture is that it allows GRUB to be large enough to allow for fairly more complex and configurable options as compared to other bootloaders.

Now that you have a fairly reasonable idea of how GRUB works, lets tweak it according to our needs and customize GRUB2 in Ubuntu.

The Basics

GRUB2 stores it’s main configuration in the /boot/grub/grub.cfg file. However, we need not edit it in any way, as we will see that it automatically gets updated. The user’s settings are stored in /etc/default/grub file. We will be editing this file to change the GRUB’s settings. Other scripts are located in /etc/grub.d/ directory.

Editing the file

First we need to install the gksu program, if not already installed. Open the terminal by pressing Ctrl+Alt+T, and type  the following command

sudo apt-get install gksu

Enter the password and press “y” or “Y” when prompted to.

install gksu

Open the configuration file by installing the following command:

gksu gedit /etc/default/grub

editing the config file

Enter the password when prompted to and the configuration file will open up in the editor.

Advertisement

config-file-opened

Choosing a background image:

By default GRUB uses a monochrome look. You can add a line in then like

GRUB_BACKGROUND=”/home/user/Pictures/Your_image.png”

to specify the image file to be used by GRUB in the background.

For e.g.

GRUB_BACKGROUND=”/usr/share/images/grub/Lake_mapourika_NZ.tga”

update background in config file

There is however a number of restrictions on the file type and format, so you can download splash images by typing the following command in the terminal

sudo apt-get install grub2-splashimages

Once installed, the images are located in the /usr/share/images/grub folder.

spalsh images

Change the Default OS

You can change the default OS, by modifying the GRUB_DEFAULT= line.Use GRUB_DEFAULT=0 uses the first entry as default, change it 1 to use the second entry as the default OS, change it to 2 for second entry and so forth.

If you want to be more specific, you can type the label, for e.g.

GRUB_DEFAULT=”Windows 7 (loader)”

Change the GRUB timeout

You can change the GRUB timeout by changing the GRUB_TIMEOUT=10 line and enter the time in seconds. For e.g.

GRUB_TIMEOUT=5

Update the changes

Type the following command to update your changes.

sudo update-grub

update changes

Restart your computer to see the changes take effect !!

Leave a Reply

Your email address will not be published. Required fields are marked *