3. How Linux Boots Up

Know How Linux Boots Up – Know the Booting Process of Linux

 

1. The Computer is powered on and the BIOS performs POST (power-On-Self-Test) which actually detects the hardware attached to the computer.

2. The BIOS will read the boot priority list and select the Boot device.

3. If the boot device is a DVD or CD drive, the drive is first checked for a media. If the media is not present, the BIOS tries to boot from the second device in the boot priority list. If the media is present, the BIOS sends commands to detect if it is bootable. If it is not bootable, the BIOS will skip and move on to the next device and then try to boot from the next device on list. If it is bootable, the CD or DVD is made to boot the computer.

4. Similarly it wil go through the list of the devices and will try to boot from each one of them.

5. When it comes to hard disk, the BIOS will command to read the first sector of the hard disk (located on sector 0, track 0). This sector is called the MBR (master boot record).

6. The GRUB boot loader can be installed onto the MBR. This means that the MBR will contain the code which will direct the CPU to load the GRUB completely.

7. loading of the main GRUB code is called STAGE 2. In case, GRUB needs some extra methods (e.g. reading a file system) to read the complete GRUB loader, an intermediate stage called STAGE 1.5 is loaded first. Only then does the things proceed.

8. Once the GRUB boot loader is in memory, it will read the file /boot/grub/menu.lst to display a menu of different OS or different boot configurations of same OS (like normal boot or failsafe boot etc). GRUB also features a command line using which you can tell GRUB what to do and how to boot an operating system.

9. If the selected option is that of Windows, it will load the boot sector of the partition which is already mentioned in the menu.lst file and make the boot sector take the control of booting Windows.

10. In case of a Linux OS being selected, GRUB will select the appropriate partition (using the root command) and loads the kernel into the memory. It also supplies the file name of the initrd (in new cases, that may be initramfs, which serves the same purpose as initrd) and passes the control to the kernel.

What is initrd?

There are zillions of hardware devices on the planet. And there are too many ways to boot up a computer. Linux kernel has support for many ways to boot from. you can boot it off an hard disk, via network, from RAID volumes and LVMs. But before calling the other parts of the operating system

such as init (see below), the kernel needs to find out where is the root file system. You can compile the linux kernel to have all the necessary features inbuilt into it to find where the root file system lies. But if you compile the full hardware support directly into the kernel, the kernel will become heavy with a lot of useless code (because you do not have all sort of hardwares attached to the file system). So an initial ram disk image is created for that kernel which contains the drivers for the different hardware and the protocols compiled into it to help the kernel find the root file system. First initrd is mounted as the root file system and it makes the drivers available to the kernel so that the kernel can find the root file system. Once the root file system has been found and the hardware drivers are loaded, the root file system is changed to the newly discovered one, thus replacing what initrd contained.

11. The Kernel now executes. Kernel will now detect the hardware connected to the computer and then load the initrd image. If the initrd was not required, it will launch the init program. 12. Once init program is loaded and executed, the first thing that it does is to read the /etc/inittab file and get the default runlevel to which the system has to be booted into.

Advertisements
Comments are closed.
%d bloggers like this: