August 29, 2011

Linux Boot Loader


In our last post we have seen basics of Linux System Initialization. Now lets take a depth look of Linux Boot Loader.

There are two possible ways to configure boot loaders:

  1. Primary Boot Loader: Install the first stage of boot loader in to the MBR but the boot loader must be configured to pass control to any other desired OS.
  2. Secondary Boot Loader: Install the first stage of boot loader in to the boot sector of any of partition on disk. But other boot loader must be installed and configured in MBR to pass control to OS.
There are two basic boot loaders used in Linux Distributions.

  1. GRUB - Grand Unified Boot Loader
  2. LILO - Linux Loader (Obsoleted)
In this article we talk about GRUB only.

Working of GRUB:

  • To select an Operating System from the HDD.
  • Identify the partition with the help of appropriate boot files.
  • Locate kernel on the HDD.
  • Run initial ram disk to set up the kernel and associated modules.

Benefits of GRUB:

  • Provides Password based security at system start up.
  • Easy to edit during boot process without making persistent changes.
  • Allows booting from WindowsXP/Vista/7 from the MBR.
  • Supports LBA (Logical Block Addressing) mode, which can help system to find the boot files if thay are beyond the 1024th cylinder on HDD.

GRUB Configuration:

Configuration of GRUB is very simple but it's vary according to the different Linux distributions.

August 27, 2011

Linux System Initialization


As a technical geek and Linux user we must have a knowledge of the Linux system Initialization process. Let's first start with its basic and will take it to the depth in upcoming articles.

When Linux system is started, there are few basic steps are involved in process.

  1. Hardware Initialization
  2. Boot Loader
  3. Kernel Initialization
  4. Init Initialization
Let's have a look at them one by one.

1. Hardware Initialization:

  • Everything on system starts with BIOS.
  • BIOS runs POST (Power of Self Test), which checks hardware.
  • It then passes control to the boot device.
2. Boot Loader:

  • Boot loader is resposible for loading and starting OS when computer is powered on.
  • It generally invoked in two ways.
BIOS passes control to an IPL (Initial Program Loader) installed within a drive's MBR (Master Boot Record).
BIOS passes control to another boot loader, which then invokes IPL installed within partition's boot sector.
  • IPL must exist within a very small space, no longer than 446 byte. So IPL for GRUB is merely a first stage whose solve task is to locate and load a second stage of boot loader which does most of the work to boot the system.
Note: GRUB is widely used boot loader on Linux based distribution.
For more details on GRUB visit our post Linux Boot Loader.

3. Kernel Initialization:

  • GRUB passes control to the kernel of respected OS.
  • Kernel detects hardware and initializes required drivers for booting of system. At the time of kernel initialization device drivers are compiled in to kernel are called and will attempt to locate their corresponding devices. If its successful in locating the devices, the drivers would be initialized and logs output to the kernel message buffer.
  • If essential drivers those are required for the booting of system have been compiled as modules instead in to the kernel then they must be included in an initrd image which is then temporarily mounted by kernel on RAM disk to make modules available for the initialization process.
  • Kernel will mount root file system read only and passes control to the init process.
  • Output of kernel messages are scrolled quickly instead use /var/log/dmesg that logs a snapshot of the kernel messages.
 4. Init Initialization:

  • Kernel then passes control to the init process. init is parent of all process. Its’ always having PID of 1.
  • /etc/inittab file contains information on how init should set up the system in every runlevel as well as default run level to use.
  • runlevel is a specific way to organize initialized software in Linux.
For more details on init  visit our post Init Configuration.