When you power on your system, you wait for some time and get Linux login prompt, there you enter your password and start your work.
Do you ever think what happens when you power on your system ???????
Here I will briefly explain what happens in between power on and log in.
4] KERNEL
Do you ever think what happens when you power on your system ???????
Here I will briefly explain what happens in between power on and log in.
Linux boot process explained in 6 stages.
1] BIOS [ Basic Input Output System ]
- After turning on the computer, the BIOS initialize the screen and keyboard and tests the main memory.
- Up to this stage, the machine does not access any mass storage media.
- Subsequently, the information about the current date, time, and the most important peripherals are loaded from the CMOS values.
- BIOS looks for boot loader in floppy, cd-rom, or hard drive.
- Once the boot loader program is detected it loads boot loader into the memory, and BIOS gives the control to it.
2] MBR [ Master Boot Record ]
- It is located in the 1st sector of the bootable disk. ( /dev/hda or /dev/sda )
- MBR is of 512 bytes. It has three components
- 1) primary boot loader info in 1st 446 bytes
- 2) partition table info in next 64 bytes ( 16 bytes each partition i.e 16 x 4 = 64)
- 3) MBR validation check or MBR signature in last 2 bytes.
- MBR contains information about where GRUB is located. (LILO in old systems).
- MBR loads and executes grub.
3] GRUB [ Grand Unified Bootloader ]
- GRUB comprises two stages.
- Stage 1 consists of 512 bytes and its only task is to load the second stage of the boot loader.
- Stage 2 contains the main part of the boot loader.
- GRUB displays a splash screen, waits for few seconds, If you have multiple kernel images installed on your system, you can choose which one to be executed. If you do not enter anything, it loads the default kernel image as specified in the grub configuration file.
- Grub configuration file is /boot/grub/grub.conf (/etc/grub.conf is a link to /boot/grub/grub.conf).
- In above image you can see, it contains kernel and initrd image
- So, now GRUB just loads and executes Kernel and initrd images.
- Kernel mounts the root file system as specified in grub.conf
- Now kernel executes the /sbin/init program.
- As init is the 1st program to be executed by Linux Kernel, it has the pid 1.
- In grub.conf image you can see initrd, 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.
5] INIT
- From the /etc/inittab file to default Linux run level is selected and all appropriate programs are loaded.
- Normally you would set the default run level to either 3 or 5.
6] Runlevel
- When system boot up, you can see various services getting started. For example, it might say “starting nagios …. OK”. That is one of runlevel programs, executed from the run level directory as defined by your run level.
- You can see runlevel programs in /etc/rc.d/rc*.d [ * is the particular runlevel no like 1, 2, 3, .... 6 ]
- For /etc/rc.d/rc*.d symbolic links are created in /etc/
e.g. /etc/rc3.d is linked to /etc/rc.d/rc3.d
- In the /etc/rc.d/rc*.d/ directories, you would see programs that start with S and K.
- Programs starts with S are used during startup. S for startup.
- Programs starts with K are used during shutdown. K for kill.
There are numbers right next to S and K in the program names. Those are the sequence number in which the programs should be started or killed.
Now you have an idea that what exactly happens during system startup.
Thank you! Keep learning!
Comments
Post a Comment