Skip to main content

LINUX BOOT PROCESS

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.



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.
4] KERNEL

  • 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

Popular posts from this blog

Linux vs Windows

We all know that there are different kinds of OS (Operating Systems). We have a domestic OS called Windows found in every nook and corner of this world, at every desk at least in India. We have flashy, highly sophisticated OS called Macintosh, found in a few rightful hands, where the owner enjoys delicious fruits of this luxurious OS. On the other hand Linux is that type of an OS which plays different roles for its owner/user, found having a friendly relationship with all its owners. :D So, now most of us who are reading this article are fed up of windows licensing problems and planning to migrate from Windows to Linux or you just want to know why Linux guys do not like Windows OS. [Image source: www.superb.net] Here, i would like to tell you one story, Suppose you go to buy a new car, you pay the amount to the respective manufacturer, then you get the keys of your new car, you are with your family very happy to buy a new car. When you drive your car out of the show

Auto FS

  Mount Filesystem using Auto FS       This document is the Operational Instruction on how to work with Auto FS file system on a Red Hat Linux Server.     This article covers the adding and mounting of Auto FS file system in a Red Hat Linux servers.   Prerequisites      ·          Need to have root privileges to make necessary changes.    ·          Take backup of /etc/exports before making any changes to this file .   ·          On Master Server: Ø   Edit /etc/exports, where an entry for the server and file system needs to be made in the following format:             /abc/pqr/xyz                                            -rw,no_root                                          server1 server2      (Dir that needs to be shared)            (Permissions)                         ( Clients to which the                                                                                                                        the filesystem needs to