Linux Boot Process Step by Step Explained | Linux Boot sequence

by Jay

On our system, multiple programmes are start in the background when we press the power button. To discover how an operating system functions, it’s crucial to comprehend the booting process. To fix the booting fault, you need to understand how the Linux kernel loads. Considering how intriguing a subject it is, let’s start with the fundamentals.

Linux Boot Process

Linux Booting Order

1. BIOS

BIOS, or Basic Input/Output System System carries out a few system integrity checks. does a search, loads the boot loader programme, and runs it.

It searches the hard disc, cd-rom, and floppy for the boot loader. To alter the boot order during BIOS starting, hit a key (usually F12 or F2, but it varies on your system).

The BIOS grants control to the boot loader programme once it has been identified and loaded into memory. Simply said, the MBR boot loader is loaded and run by BIOS.

2. MBR

Master Boot Record is known to as MBR.

It is situated in the bootable disk's first sector. Normally, the MBR for /dev/hda or /dev/sda is no larger than 512 bytes.

There are three parts to this.

1. Information about the primary boot loader is contained in the first 446 bytes

2. Followed by information about the partition table in the following 64 bytes.

3. Last two bytes of the mbr validation check.

It includes details about GRUB (or LILO in old systems). Hence, to put it simply, the MBR loads and runs the GRUB boot loader.

3. GRUB

Grand Unified Bootloader is referred to as GRUB.

If there are multiple installed kernel images on your system, you can choose which one to execute.

GRUB shows a splash screen, waits a short while, and then loads the default kernel image as provided in the grub configuration file if you don't type anything.

GRUB is aware of the filesystem, unlike the earlier Linux loader LILO, which was not.

"/boot/grub/grub.conf" is the grub configuration file, and "/etc/grub.conf" is a link to it.
Below is a CentOS sample grub.conf file:

    #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

It contains a kernel and an initrd image, as you can see from the information above.

Therefore, to put it simply, GRUB just loads and runs the kernel and initrd images.

4. Kernel

grub's "root=" command mounts the root file system as given conf. The /sbin/init programme is run by the kernel.

The Linux Kernel's first programme to run, init, has the process id (PID) of 1. Check the pid by performing a "ps -ef | grep init."

Initial RAM Disk is referred to as initrd.

Until kernel boots and the real root file system is mounted, kernel uses initrd as a temporary root file system.

Moreover, it has all essential drivers built-in, enabling access to hardware such as hard drive partitions.

5. Init

The /etc/inittab file is advised to determine the Linux run level.

The available run levels are listed below.

    0 – halt
    1 – Single user mode
    2 – Multiuser, without NFS
    3 – Full multiuser mode
    4 – unused
    5 – X11
    6 – reboot

Init uses the default initlevel found in /etc/inittab to load all necessary programmes.

On your system, execute "grep initdefault /etc/inittab" to find the default run level.

You can change the default run level to 0 or 6 if you want to get into trouble. Since you are aware of what 0 and 6 signify, you probably won't do that.  Normally, you would choose either 3 or 5 as the default run level.

6. Runlevel programs:

While the Linux operating system boots, you could see that several services are starting up. 

As an illustration, it might read "beginning sendmail… Fine." These are the runlevel programmes, which are run from the run level directory that your run level has specified.

Programs from one of the following directories will be executed by the system depending on your default init level setting.

    Run level 0 – /etc/rc.d/rc0.d
    Run level 1 – /etc/rc.d/rc1.d/
    Run level 2 – /etc/rc.d/rc2.d/
    Run level 3 – /etc/rc.d/rc3.d/
    Run level 4 – /etc/rc.d/rc4.d/
    Run level 5 – /etc/rc.d/rc5.d/
    Run level 6 – /etc/rc.d/rc6.d/

Please be aware that symbolic links are also available under "/etc" for these directories. As a result, "/etc/rc0.d" and "/etc/rc.d/rc0.d" are linked. 

You can find programmes that begin with S and K under the "/etc/rc.d/rc*.d/" directories. 
During booting, programmes that begin with S are used for startup. S is utilised at the start.
Programs with K are used when the system is shutting down. kill signal
The letters S and K are followed by numerals in the programme titles.

These are the order numbers in which the programmes must be initiated or terminated.

S12syslog, for illustration, will launch the syslog deamon, which has the sequence number 12. The sendmail daemon, which has the sequence number 80, is to be started with the command s80sendmail.  As a result, the Syslog software will launch before Sendmail.

Related Posts

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.