A Basic Guide to Linux Boot Process

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 DiskCD-ROMRAM, 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 UNIXLinux 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
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

PCI PASS-THROUGH ON XENSERVER 7.0

PCI PASS-THROUGH ON XENSERVER 7.0 Plenty of people have asked me over the years how to...

Re-Install OS

Re-Install OS     To Re-Install OS, go to VPS Management Page and click on "OS...

How To Assign Output of a Linux Command to a Variable

When you run a command, it produces some kind of output: either the result of a program is...

How to Auto Execute Commands/Scripts During Reboot or Startup

I am always fascinated by the things going on behind the scenes when I boot a Linux system and...

20 Useful Commands of ‘Sysstat’ Utilities (mpstat, pidstat, iostat and sar) for Linux Performance Monitoring

In our last article, we have learned about installing and upgrading the sysstat package and...