Friday 3 January 2014

LINUX BOOT PROCEDURE


Linux booting procedure is an important and interesting knowledge point for the system admin. It will help SA to understand how linux works and probably will help SA to recover a Linux system in emergency situation.

Basically a X86 Linux rebooting procedure as below:



Step 1: POST

It is usually called Power On Self Test (POST): it is the hardware checking: CPU, Memory, IO, network card. Etc. it is independent of the Linux booting. At the end of the process it Searches, loads, and executes the boot loader program. And give the control to MBR

Step 2: MBR

MBR stands for Master Boot Record.It is located in the 1st sector of the bootable disk. Typically /dev/hda, or /dev/sda
MBR is usually 512 bytes in size (1 sector of the disk). This has three components
  1. primary boot loader info in 1st 446 bytes (header of GRUB)
  2. partition table info in next 64 bytes
  3. mbr validation check in last 2 bytes.

It contains information about GRUB (or LILO in old systems).
It will executes the GRUB boot loader in the end.

Step 3: GRUB.

GRUB displays a splash screen, waits for few seconds, if you don’t enter anything, it loads the selected kernel image as specified in the grub configuration file.
Besides the title, and the root partition location, it contains kernel with parameters and initrd information.
title CentOS (2.6.32-279.el6.i686)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-279.el6.i686 ro root=/dev/mapper/vg_hadoop-lv_root rd_NO_LUKS rd_LVM_LV=vg_hadoop/lv_swap LANG=en_US.UTF-8 rd_LVM_LV=vg_hadoop/lv_root rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        initrd /initramfs-2.6.32-279.el6.i686.img

step4: KERNEL

In this stage: initrd (initial RAM disk)is used by kernel as temporary root file system until kernel is booted and the real root file system is mounted. It also contains necessary drivers compiled inside, which helps it to access the hard drive partitions, and other hardware 
then the OS will mount / file system and kick off /sbin/init – the pid 1 process in linux.

Step 5: INIT:

At this stage, init 1 process was kicked off.
Init identifies the default initlevel from /etc/inittab and uses that to load all appropriate program.

Step 6. RUNLEVEL

It will run the scripts according to the run level decided in previous steps.
It will also run /etc/rc.d/rc.sysinit.
In this stage, the kernel will do most of user related activites such as
  • Activated udev and selinux
  • Set kernel parmarmeters from /etc/sysctl.conf
  • Set system clock
  • Set swap
  • Set hostname/network
  • Mount other file systems
  • Get ready virtual terminals (tty)
  • Run customized scripts (service)


1 comment: