As a system administrator you should have an understanding of the Linux booting process.  In this post, you will learn about BIOS, the boot loader, the Linux kernel and Runlevels.

 

Linux booting process

Lets discuss and Understand the Linux booting process one by one

The BIOS

 

The BIOS stands for Basic Input/Output System.  It’s a firmware used in the booting process and it’s the first piece of software that is executed when a computer is powered on.  The BIOS is doesn not depend onthe OS type, rather it is independent.

Its primary purpose is to test the hardware on the motherboard by executing Power On Self Test and to load a boot loader or operating system. The POST performs some basic checks of hardware components such as the CPU, memory, and storage devices.  Only if the POST succeeds, the BIOS attempt to load the boot loader.

The BIOS contains a list of bootable devices such as hard disks, DVD drive, USB devices, and others depending on what hardware is connected.

The BIOS searches the list for a bootable device in the order of boot priority.  You can change this order by getting into BIOS configuration by interrupting the boot sequence.  The key combination used to do this will be different from one hardware manufacturer to another.

Once a bootable device has been found, the BIOS runs the boot loader.  Generally the GRUB boot loader will be used, but there are other boot loader too like, LILO boot loader.  LILO is an abbreviation for LInux LOader, while GRUB stands for GRand Unified Bootloader.

The primary purpose of the boot loader is to start the operating system.  You will see a series of messages from the boot loader. These messages provides an option to interrupt the boot process and interact with the boot loader.  If there are multiple operating systems installed, you can select one.  You can also instruct the boot loader to pass different boot options to the operating system.

The Initial RAM Disk

The initial RAM disk, also known as “initrd,” is a temporary file system that’s loaded into RAM. when the linux booting process starts,  this file system contain helpers that perform hardware detection and load the necessary modules, sometimes drivers, to get the original file system mounted.  Suppose that, if the root file filesystem is located on an LVM (Logical Volume Manager) volume, the initrd image will contain the modules required to mount that logical volume as the root file system.  Once the root file system is mounted the job of initrd is done and the operating system continues loading from the actual root file system.

Kernel and Initial RAM Disk Location

The Linux kernel, the initial RAM disk, and other files needed to boot the operating system are stored in /boot.  Here is a list of contents in /boot directory for a linux system.

$ ls -1F /boot

abi-3.13.0-46-generic
config-3.13.0-46-generic
grub/
initrd.img-3.13.0-46-generic
System.map-3.13.0-46-generic
vmlinuz-3.13.0-46-generic

 

The Kernel Ring Buffer

The kernel ring buffer contains messages related to the Linux kernel.  A ring buffer is a data structure with almost constant size. If the buffer is completely full, old messages are discarded .To see the contents of the kernel ring buffer, use the command –

#dmesg

Runlevels and Targets

The last step in Linux booting process is Runlevel. Linux uses runlevels to decide which processes and services to start. The Runlevels are mentioned below :

0  :Shuts down the system
1  :Single user mode.?Used for maintenance.
2  :Multi-user mode with graphical interface. (Debian/Ubuntu)
3  :Multi-user text mode (RedHat/CentOS)
4  :Undefined
5  :Multi-user mode with graphical interface. ?(RedHat/CentOS)
6  :Reboot

Previously, runlevels were controlled by the init program.  The init configuration was stored in /etc/inittab. To change the default runlevel using init, you would edit the /etc/inittab file. However, init alternatives such as systemd and upstart are quickly taking the place of init with systemd currently being the most widely used.

Instead of runlevels, systemd has the targets.  These targets are equivalent to runlevels.  You can find the list of available targets in /lib/systemd/system. The runlevel targets are actually symbolic links to the real targets.  For example, runlevel5.target is a symlink to graphical.target.

Rebooting a System

For rebooting you can use the reboot or shutdown commands as well as the runlevel/target.

Here’s how to reboot with init using coomand :

# telinit 6

To reboot using systemd use the systemctl command :

# systemctl isolate reboot.target

To reboot using the reboot command :

# reboot
The format of the shutdown command is as follows :

shutdown [options] time [message]

The option to use reboot with shutdown format is  -r. 
You can specify the time to shutdown using the “HH:MM” format.
You can also use +N where N represents the number of minutes to wait.  Finally, you can use the “now” keyword to start immediately.  Optionally, you may specify a message that will be broadcast to all users logged into the system.

# shutdown -r now

Powering Off a System

To power off a system, you can use runlevel 0, the poweroff target, or the poweroff command. we can power-off with init by executing following command :

# telinit 0

Power off a system with systemctl :

# systemctl isolate poweroff.target

Finally, you can use the poweroff command :

# poweroff

If you need to refresh on what is Linux, refer this post. 

Leave a Reply

Your email address will not be published. Required fields are marked *