Did You Know?
Ask a Question

We are pleased to announce the Launch of our New Section "TecMint Ask"

A Basic Guide to Linux Boot Process

Download Your Free eBooks NOW - 10 Free Linux eBooks for Administrators

As promised in our earlier post, in this post we are going to review boot process in Linux Operating System. How Operating system passes through different stage of booting states. This article is written for those readers who has just steps in Linux world. Understanding how Linux boots up is very important in terms of effectively troubleshooting in case of system failure. When a system switched on and after few moment we get a login prompt. Have we try to find out what all stage of booting sequence has crossed and what happened behind the scene during system boots up.

Linux Boot Process

Linux Boot Loader Process

Power on

  1. BIOS (Basic Input Output System) is a software program comes pre-built in a motherboard chipset.
  2. BIOS loads and scans for devices such as Hard Disk, CD-ROM, RAM, etc.
  3. BIOS searches for MBR (Master Boot Record: 1st sector) of the primary hard drive, it scans for 1st stage loader (In our case boot loader is (GRUB LILO) and hands over the responsibility to MBR.
  4. Boot PROM/FLASH/BIOS is proficient of loading the MBR into RAM and executing it.

MBR (Master Boot Record)

  • 512 bytes of space –> MBR
  • MBR contains the information of loader of most operating system e.g UNIX, Linux and WINDOWS
  • MBR holds the small binary information of 1st stage of loader
  • MBR consist physical sector of the first disk drive (i.e 512 bytes) and it’s not part of any partition.
  • Placed on the prime disk drive, in the prime sector of the first cylinder of track is 0 and head is 0 (this whole path is generally booked for boot programs)
  • MBR involve a mini executable programs and a table specify the primary partitions.
Boot Code (GRUB) 446 bytes
partition 1: 16 bytes
partition 2: 16 bytes
partition 3: 16 bytes
partition 4: 16 bytes
magic Number: 2 bytes
  1. MBR also document which primary partition is ACTIVE.
  2. The BIOS surrender rights to the first stage boot loader, which then scans partition table and finds second stage boot loader on the partition configured as bootable.

Boot Loader

  1. The boot loader termed from 1st stage loader and loads itself into RAM. All this go on in milliseconds.
  2. The default stage 2 boot loader is a GRUB (Grand Unified Boot Loader) or LILO (Linux Loader)
  3. Once GRUB is loaded into RAM, then it’s search for the location of Kernel.
  4. GRUB will scrutinize the map file to find the kernel image, that is located under (/boot) and load it.
  5. GRUB loads the kernel (vmlinuz-version) from /boot partition

Trivia 1

GRUB organize RAMDISK for initrd —> (RAMDISK is reserved space from RAM). In addition, it drives initrd into RAM to ready the kernel for loading itself into memory and depended modules so that it can leave the system to “init” process

In, Linux most of the drivers are pre-built as modules, these would be initial ram drive (initrd.img) where it can keep all the information of additional modules. So, when the kernel boots, it creates ramdrive, loads the initrd.img and its depended modules.

GRUB reads /boot/grub/grub.conf & shows us a clean interface for selecting Operating System

Once Kernel loads its depended modules and then it hand over to “init” process. The kernel image has a small, unpacked program that un-compresses kernel and runs it.

Trivia 2

LILO needed to indicate MBR in order to locate operating systems on the hard drive. Any modifications done to /etc/lilo.conf, that must be updated in MBR, but in GRUB‘s case no need to update, it reads directly from the file /boot/grub/grub.conf.

After making changes in /etc/lilo.conf, we’ll have to update the MBR manually

# /sbin/lilo -v

Trivia 3

The GRUB second stage loader resides within the MBR and within /boot partition. Once GRUB is loaded into memory it becomes 2nd stage loader.

Trivia 4

The /initrd directory should not be removed it is a temporary place holder for kernel to have quick access to the modules that it needs to start the system modules include device drivers.

Kernel initialization highlights include:

  1. initialize CPU components, eg, MMU
  2. initialize the scheduler (PID 0)
  3. mount the root filesystem in rw mode
  4. fork off the init process (PID 1)

In essence, kernel initialization does two things:

  1. Start the core system of shared resource managers (RAM, processor and mass storage).
  2. Starts a single process, /sbin/init.

Init process (sbin/init) is the very fist process which loads all the various daemons and mounts all the partitions which are listed under /etc/fstab.

About /etc/fstab

  1. The /sbin/init reads /etc/inittab file
  2. Set default runlevel ( the telinit command allows administrators to tell the init process to change its current runlevel)
  3. Calls /etc/rc.d/rc.sysinit and /etc/rc.d/rc x (where ‘x‘ is a runlevel)
  4. In /etc/rc.d/rc5.d directory files starting with letter K –> kill scripts and files starting with letter S –> Startup scripts.
  5. Start up the tty processes and xdm ( X display manager)
  6. Starts User’s login screen
He has over 10 years of rich IT experience which includes various Linux Distros, FOSS and Networking. Narad always believes sharing IT knowledge with others and adopts new technology with ease.

Linux Services & Free WordPress Setup

Our post is simply ‘DIY’ aka ‘Do It Yourself, still you may find difficulties and want us to help you out. We offer wide range of Linux and Web Hosting Solutions at fair minimum rates. Please submit your orders by Clicking Here.

4 Responses

  1. Pradeep Kumar says:

    Hi ,

    Boot Loader stages are missing in booting process

  2. Mohd.Tabrez says:

    Hi,
    could anyone let me know about the bootable files in linux?

  3. aprogrammer says:

    Here is article with deep runlevel testing if anybody need if – http://sysadmin.te.ua/linux/linux-boot.html

Leave a Reply

© 2012-2013 All Rights Reserved.