How a Linux Machine Boots?

How a Linux Machine Boots?

Share Now
3 min read
662

How A Linux Machine Boots? Let’s check out the sequence that takes place during booting up a Linux machine is as follows below.

BIOS :- Basic Input / Output System:

  • Performs some system integrity checks.
  • Searches, loads, and executes the boot loader program.
  • It looks for the bootloader in floppy, cd-rom,or hard drive. We have options to change the boot sequence by pressing F2
  • Once the bootloader program is detected and loaded into memory, BIOS gives the control to it.
  • So, BIOS loads and executes the MBR bootloader

MBR: Master Boot Record:

  • It is located in the 1st sector of the bootable disk, typically /dev/hda or /sda.
  • MBR is less than 512 bytes, this has 3 components.
  1. Primary bootloader info in 1st 446 bytes
  2. Partition table info in the 64 bytes.
  3. MBR validates check in the 2 bytes.

It contains information about GRUB (LILO is old systems)

GRUB: Grand Unified Bootloader

  • If you have multiple kernel images installed on your system, you can choose which one to be executed.
  • GRUB displays a splash screen. Waits for a few seconds, if you don`t enter anything, it loads the default kernel image as specified in the grub configuration file.
  • GRUB has knowledge of the filesystem.
  • Grub configuration file is /boot/grub/grub/grub.conf (/etc/grub.conf is a link to this).
  • Eg for CentOS the grub.conf is.

So, as shown above, both kernel and initrd images are available on grub.conf file.

KERNEL:

  • Mount the root file system as specified in the “root=” in grub.conf
  • Kernel executes the /sbin/init program
  • Since init was the 1st program to be executed by the x kernel, it has the process ID (PID).
  • Do, ps –ef | grep init and check the PID
  • Initrd = Initial RAM Disk.
  • Initrd is used by the kernel as a temporary root file system until the kernel is booted and the root file system is mounted. It also contains necessary drivers compiled inside which helps it to access the hard drive partitions and other hardware.

INIT:

Looks at the /etc/inittab file to decide the Linux run level.

The following are the available run levels.

  • 0-Halt
  • 1-Single User Mode
  • 2- Multiuser without NFS.
  • 3-Full multiuser mode
  • 4-Unused
  • 5- X11
  • 6- reboot
  • Init identifies the default inilevel from /etc/inittab and uses that to load all appropriate programs.
  • Execute “grep initdefault /etc/inittab” on your system to identify the default run level.
  • Don`t set your default run level to 0 and 6.
  • Set to 3 or 5.

Runlevel Programs:

  • When the Linux system is booting up, you might see various services getting started, For Example, it might say “Starting sendmail .. OK”. Those are the runlevel programs, executed from the run level directory as defined by your run level.
  • Depending on your default init level settings, the system will execute the programs from one of the following directories.

Run level 0 – /etc/rc.d/rc0.d/

Run level 1 – /etc/rc.d/rc1.d/

———-

———-

Run level 6 – /etc/rc.d/rc6.d/

Please note that there are also symbolic links available for these directories under /etc

So, /etc/rc0.d is linked to /etc/rc.d/rc0.d

  • Under the /etc/rc.d/rc*.d/ directories, you would see programs that start with S and K.
  • The program starts with “S” are used during Startup; S= Start-up.
  • The program starts with “K” are used during Shutdown; K = KILL.

There are numbers right to “K” & “ S”, they are the sequence number in which the program should start or kill.

Eg :

  • S12syslog is to start the syslog daemon, which has a sequence number of 12.
  • S80Sendmail is to start the Sendmail daemon, which has a sequence number of 80.

So, syslog program will be started before sending mail.

We will write more in detail about Linux and various cloud computing technologies. Contact us for more details on LINUX, Cloud Computing AWS, and Azure. Comment below if you have any query on “How A Linux Machine Boots”. Thank you

Leave comment

Your email address will not be published. Required fields are marked with *.