Kindly explain the linux booting process with simple language as I didn’t understand the answer that is explained in this website. So I want it in a simple and easy language so that I can answer in interview. So please explain step by step in details.
Hi Druva,
Boot Processes is done in six stages after you power on the system
- BIOS
- MBR
- GRUB
- Kernel
- Init
- Runlevel programes
let us go into deep
1) BIOS
BIOS stands for Basic Input/Output System when you power on the system BIOS will comes into field and it checks for the boot loader program.
It looks for boot loader in floppy, cd-rom, or hard drive. Once the boot loader program is detected and loaded into the memory, BIOS gives the control to it.
So, in simple terms we can say that BIOS loads and executes the MBR boot loader.
BIOS ---------> MBR (which consist’s boot loader)
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 less than 512 bytes in size.
This has three components 1) primary boot loader (for which BIOS looks) info in 1st 446 bytes 2) partition table info in next 64 bytes 3) mbr validation check in last 2 bytes.
MBR contains information about GRUB (or LILO in old systems).
So, in simple terms we can say that MBR loads and executes the GRUB boot loader.
BIOS ------> MBR(which consist’s boot loader) + information about GRUB--------> GRUB
3) GRUB
GRUB stands for Grand Unified Bootloader. If you have multiple kernel images installed on your system, you can choose which one to be executed. Below image shows the Grub screen
actually the above screen shot is taken after pressing e (editing the kernel)
GRUB displays a splash screen, waits for few seconds, if you don’t enter anything, it loads the default kernel image as specified in the grub configuration file.
NOTE Grub(grub.conf) file consists of three kernel and initrd images by default
GRUB has the knowledge of the filesystem (the older Linux loader LILO didn’t understand filesystem).
Grub configuration file is /boot/grub/grub.conf
if you don’t like the flash screen you can disable it by editing the above file grub.conf
#vim /etc/grub/grub.conf #boot=/dev/sda default=0 timeout=5 #splashimage=(hd0,0)/boot/grub/splash.xpm.gz --------> hide this line 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
The above grub file shows you kernel and initrd images, so simply we can say that it executes kernel and initrd images
BIOS ------> MBR -------> GRUB (kernel+initrd) ---------> Kernel
NOTE Some time’s grub will be corrupted at that time you have to do troubleshooting
4) Kernel
Mounts the root file system Kernel executes the /sbin/init program
Since init was the 1st program to be executed by Linux Kernel, it has the process id (PID) of 1. Do a ‘ps -ef | grep init’ and check the pid.
initrd stands for Initial RAM Disk.
initrd 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 and the initrd image is located under /boot
NOTE If initrd file corrupts you will stuck at boot processes you need to trouble shot is
5) INIT
Looks at the /etc/inittab file to decide the Linux run level.
Following are the available run levels
0 – halt
1 – Single user mode
2 – Multiuser, without NFS
3 – Full multiuser mode
4 – unused
5 – X11 -------> Graphycal User Interface
6 – reboot
Init identifies the default initlevel from /etc/inittab and uses that to load all appropriate program.
#grep initdefault /etc/inittab’
Execute the above command on your system to identify the default run level
If you set the default run level to 0 or 6 your system continuously shutdowns (0) or reboots (6) .
Typically you would set the default run level to either 3 or 5.
6) Runlevel programs
When the Linux system is booting up, you might see various services getting started. For example, look at the below image
Those are the runlevel programs, executed from the run level directory as defined by your run level.