Tuesday 28 June 2016

Linux Booting Process

Hi we are going to see the booting process of linux. I actually wanted to know how it's working still i want to make it to know to every one. Sorry my english will be little bit bad may be more bad. Ok let's look into it.

Linux Booting Process:

Before that we have to know some other things in this that make it PC boot and communicate with OS. I mentioned that files in below. 

Bios - Basic Input/Output System executes MBR
MBR - Master Boot Record Executes GRUB
GRUB - Grand Unified Bootloader executes Kernel
Kernel - Kernel executes /bin/init
Init - Init executes the runlevel programs
Runlevel - Runlevel programs are executed from /etc/rc.d/rc*.d/

BIOS :
  • Bios performs some integrity checks.
  • It searches, loads,and executes the boot loader.
  • BIOS looks for the boot loader file in booting device if it's found then it will loaded into memory and gives the control to it.
  • So it's simple terms of BIOS is load and execute the MBR.
MBR :
  • MBR is stands for Master Boot Record
  • It's located in first sector in the bootable disk. It typically locate in /dev/hda or /dev/sda.
  • MBR is less than 512 bytes in size.
  • It has three components 1. primary boot loader info  in 1st 446 bytes. 2. partition table info in next 64 bytes. 3. mbr validation checks in last 2 bytes.
  • It contains GRUB information. In old systems it contains information about LILO.
GRUB :
  • Grub stand for Grand Unified Bootloader.
  • If we have multi OS installed then it will give a option to choose the options.
  • It's only give us the flash screen that contains to choose the option like bios or boot option or something else..,
  • If we didn't select anything then it will load the default kernel image that specified in the grub.
  • It has the knowledge of the filesystem. but older LILO doesn't have that.
  • It located in /boot/grub/grub.conf and /etc/grub.conf is link to this. Below i mentioned the sample Grub conf.
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-194.el5PAE)
          root (hd0,0)
          kernel /boot/vmlinuz-2.6.18-194.el5PAE ro root=LABEL=/
          initrd /boot/initrd-2.6.18-194.el5PAE.img

  • you can notice baove that have the info about kernel and init image.
Kernel :

  • Kernel mount the root file system as specified in the "root=" in grub.conf
  • Kernel executes the /sbin/init program. initrd stands for initial RAM Disk.
  • Kernel uses the initrd as temporary root file system until kernel boot and the real root file system mounts.
  • It's also contains necessary drivers compiled inside. Which it helps as to access the hard drive and other hardware in PC.
Init :

In linux we have 6 runlevels it located in /etc/inittab. Below linux runlevels are mentioned.
  • init0 - Shutdown - /etc/rc.d/rc0.d/
  • init1 - Single User mode - /etc/rc.d/rc1.d/
  • init2 - Multiuser mode, without NFS - /etc/rc.d/rc2.d/
  • init3 - Full Multiuser mode - /etc/rc.d/rc3.d/
  • init4 - Not Used - /etc/rc.d/rc4.d/
  • init5 - GUI - /etc/rc.d/rc5.d/
  • init6 - Reboot - /etc/rc.d/rc6.d/
Init identifies the default runlevles from /etc/inittab and load all the apprpopriate programs. It's depends on your default init level that system will execute the program from above mentioned directories.

Note there is alos symbolic links available for these directories under /etc/rc0.d is linked to /etc/rc.d/rc0.d.

We can also see under the /etc/rc.d/rc*.d/ directories that starts with S and K. S means startup and K means kill the programs when shutdown. Also there is number in next to S and K in program names. Those are the sequence number in which programs should start or killed.

This is also I have taken from another website and i have modified for my own understanding.

Thanks and if you like this follow my link.


No comments:

Post a Comment

Permanent hostname setup for RHEL7

Step 1 Set the host name on NMTUI tool like following nmtui set host name   then save and exit Step 2 add the following l...