jump to navigation

The Linux boot process January 31, 2011

Posted by Tournas Dimitrios in Linux.

This article will outline the main steps that are essential for booting a Linux box . These steps must be well understood , as they will be the foundation to do maintenance tasks or to  troubleshoot a non-booting Linux machine .  From the time that the power is switched on , until users are able to log in to a fully functioning machine , the system passes through four distinct stages of initialization :

  1. BIOS : The minimal operating system which is located in the ROM of the system’s motherboard
  2. Bootloader : This minimal application (GRUB) which is located on the disk’s MBR , used to load and pass control to the Linux kernel .
  3. Kernel : Firstly it initializes device drivers , starts the first process (init) and lastly during the operation of the computer act’s  as  the control center of the computer .
  4. /sbin/init : This process performs most of the hard work to initialize the machine .

See the picture below to get a 20000 meters high view of the process .


First step : The BIOS performs an integrity check of the system , ensuring that all core components (CPU ,Hard discs ,  Basic Input / Output System etc…) are ” in-place ” and ready to get started . The next step is to locate the appropriate  boot device . Usually it searches in a  ” sequential order ”  , first looking for a bootable floppy , and if not present  “flips ” to the next device (ie a bootable CD-ROM) and finally looking for a bootable hard disk . The order of the sequential search is usually configurable through the BIOS menu .Finaly the BIOS  loads the first part of the boot loader and pass the control to this application .

Second step : The bootloaders on Linux have three responsibilities :

  1. Acting as an command line interface to pass arguments to  the kernel at booting .
  2. Loading an appropriate initial ram disk (initrd)
  3. Loading and passing control to the appropriate Linux kernel

Bootloaders are usually designed in two stages , with the first stage small enough to reside in a Master Boot Record (464 Bytes ) , and the second part on the hard disk .

The Kernel on Linux is usually created as a modular component and drivers are loaded as module – elements when needed . This choice naturally leads to a problem . From where does the kernel load its kernel modules . if they are needed in the boot process before the filesystem is created ?  (mounted) . The answer is an initial ramdisk , which is a filesystem image which contains the necessary modules . The boot loader loads the  ramdisk image into memory for the kernel , from where the kernel  can trivially mount the filesystem and load any necessary modules  .

Third step : At this point the kernel with its modules (initrd) are loaded in RAM . Essentially a system administrator can view the kernel as performing these three steps :

  1. Replace all BIOS device drivers with Linux device drivers
  2. Mount the root partiton read – only .
  3. Start the first process (init ) .

And that’s it . The kernel does remarkably little to initialize the system , relying on the first process (init ) to do all of the hard work .

Fourth step : /sbin/init process receives  a system that has only mounted the root partition read –  only and  delivers all hard disk’s  checked for errors , mounted r/w and full featured ready for operation . These are the key points that are executed in the exact order  :

  • /sbin/init reads the /etc/inittab configuration file to decide what runlevel it should start .
  • /sbin/init runs the bash script /etc/rc.sysinit (softlink of /etc/rc.d/rc.sysinit)
    • sysinit reads /etc/fstab to decide which partitions must be mounted
    • sysinit receive a root filesystem mounted r/o  and delivers a all partitions checked – mounted r/w .
    • depending on configuration of the inittab file , the scripts  in a specific directory will be executed .
      vs for runlevel 3 –> /etc/rc.d/rc3  ,
      for runlevel 5 –>/etc/rc.d/rc5  etc…..
  • As init is the mother of all processes it is now ready to act accordingly . It delivers a log – in to the user .


1. Password protect the bootloader on Centos 5.x « Tournas Dimitrios - February 1, 2011

[…] The Linux boot-process […]

2. Troubleshooting a non-booting Linux box « Tournas Dimitrios - February 1, 2011

[…] up until after rc.sysinit is finished . If you need a refresh for the boot sequence read first this article before you continue […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s