System Initialization

17 October, 2020


Related Blogs


Linux - System Initialization

Boot process:

Boot process consists of the set of processes from power on the PC to login prompt comes. When a computer boots up, the BIOS is the first program that is run. After it is loaded, the BIOS begins to test the system through the power on Self Test (POST) and then starts loading peripheral devices. The BIOS then looks for the boot device and passes control to it. The boot device contains the Master boot record (MBR), Which starts to boot the system via the boot loader. From here, the Grand unified boot loader (GRUB) looks to boot into the kernel that is labeled as the default. Finally, the kernel calls the init process, which boots up the rest of the system. The GRUB has become the default boot loader for Red Hat, ebonite, and many; other versions of linux as well When GRUB loads, you are given a list of kernels and additional operating systems from which you can choose to boot. By default, there is a configurable 5-second timeout value that chooses the default kernel if you don’t make a selection and the timeout there should is reached/ After GRUB loads the kernel, it passes control over to the kernel, which it run begins to initialize and configure the computer’s hardware. During the boot process, everything is logged to the /var/ log/ dmesg file. You can also use the dmesg cmd to query information about the boot process after the system has booted. When the system’s drivers are in place, the kernel executes the /sbin / init program. In RHEL 6, the boot process has been replaced by a new utility called upstart instead of the traditional system in its style scripts. This utility decreases the time that it takes the system to boot and is already currently being used on other versions of lixun such as ubuntu. The init program is the first process created by the kernel. It is responsible for the rest of the boot process and setting up the environment for the user. First, it consults the /etc/init tab file, which defines how the rest of the boot process will go. The /etc/init tab file lists the default run level to boot into and the system initialization script (etc/rc.d/rc.sysinit). Let’s look at the /etc/init tab file to see what the init process goes through #cat/etc/init tab You can see that the default run level is set to 5, although six different run levels are listed. The /etc/init tab file also defines how to handle power failures and virtual terminals. After the init process is done consulting the /etc/init tab file, the /etc/rc.d/rc.sys, init script is run,  which handles setting the system clock, networking, setting up the user environment & more. In Red Hat Linux, the default run level is 5. This default run level is passed to the /etc/rc.d /rc script, which calls all the programs in the /etc/rc.d/rc#.d directory. The last thing that you should see is the login prompt. If you have a desktop manager installed such as Gnome, you should see a GUI login screen where you can log in to the system; otherwise, you see a text mode login. Working with Grub: The GRUB boot loader is broken down into different stages. The code contained on the MBR is considered GRUB stage 1. It loads GRUB stage 1.5, which tries to identify the file system type (optional), or it can call GRUB stage 2 directly. Stage 2 is what calls the kernel and loads it into memory. In stage 1, GRUB needs to search the MBR looking for an active partition from which to boot the kernel. GRUB has its own format for looking through hard disks. The syntax of this format is (xdn[, m])            where xd is the drive

  • n is the number of the disk
  • m denotes the partition number.
  • The syntax is very useful when troubleshooting issues with GRUB because you need to know how GRUB searches for disk drives when trying to find the primary partition. When the primary partition found, GRUB loads the kernel, which is where you move to stage 2. Stage 2 is the place where you will tend to spend the most time troubleshooting boot issues with the system. As stage 2 starts, it presents you with a list of kernels that you can boot from, along with a listing of options that you can use to modify the parameters passed to the kernel during bootup.

Grub Boot options:

e    ---->         Edit the cmds before booting

a    ---->           Modify (or) append the kernel arguments before booting

c       ---->        open the GRUB cmd line.

  • You can use the ‘a’ option to modify any parameters you want to pass to the kernel. This includes changing the run level that the system will boot into.
  • After choosing the ‘a’ option, you can pass a mode as a parameter to enter into the mode. Here are the different modes that you can booty into:

Single – User Mode

------> perform maintenance tasks (or) forget the root password. Run level 2 (or) 3

------> Load only partial services during the boot process Emergency Mode

------> used to perform tasks on an unbootable system. Rescue Mode

------>  used to fix boot issues (or) reinstall GRUB.  

The Config file:

GRUB has only a single config file, /boot/ grub/grub.conf. Two other files actually have soft links to this main config file as well: /boot/grub/menu.lst and /etc/grub.conf. When GRUB starts, it reads its configuration from the main config file # cat /boot/grub/grub.conf Using the C option to enter the GRUB cmd line, you can make changes to the config file, reinstall GRUB, or repair a broken config file.

Inclined to build a profession as Linux Developer? Then here is the blog post on, explore Linux Training

The GRUB Command Line:

How to repair a broken MB You need to make use of the rescue environment, which can be found by booting from the RHEL installation DVD. When you are in the rescue environment, you can repair your broken MBR.

Step1: Load up the GRUB cmd line to find the disk and partition that contain the grub conf file using the find cmd. Grub> find           /grub/grub.cong (hd ʘ, ʘ) àyou could also run: Grub>root (hd ʘ, ʘ)

Step 2: Install GRUB on the drive is returned: Grub> setup        ((hd ʘ) ------> Now that your MBR is fixed, you should be able to boot the system once again.

  • Runlevels:

------> when the system boots up, it queries for the default run level, which is defined in the /etc/init tab file. When the default run level is located, the system boots into that particular run level. ------> There is a six-run level in total which are shown in the /etc/init tab file. Each run level also has a directory called /etc/rc.d/rc#.d, where  # is the run level (from 0 to 6). 

Let’s look at the different run levels:

0   ------>          halt

1   ------>          single-user mode

2   ------>          multiuser with partial services

3   ------>          Full multiuser with networking (text mode)

4   ------>          not used

5   ------>          Full multiuser graphical mode (GUI desktop login)

6   ------>          Reboot

------> The easiest runlevels to understand are 0 and 6. These two run levels are called by the same cmd with different input. In runlevel 0, essentially the system is off. In run level 6, the system is restarting. Runlevel 1 is used to enter single-user mode, which you would enter if there are issues with the system and you’d like to perform maintenance. You can also reset the root user’s password at this run level. The remaining runlevels provide various states for different services to run it ------> Don’t forget the upstart is the program that actually starts & stops services at each run level now. The /etc/init/ rc.conf file shows how each set of scripts is called: #cat /etc/init/ rc/conf

Runlevel Utilities:

Let’s now look at the many system utilities that help you manage the system in different run levels. This management cmds are Sys: Shutdown [options] time

  • -k     ------>         doesn’t shut down; just warns
  • -h     ------>        Halts the system after shutdown
  • -r      ------>        Reboots instead of turning off the system
  • -F     ------>         Forces a file system check on reboot.
  • -n     ------>        kills all processes quickly (not recommended)
  • -t       ------>       SECS sends a shutdown message but delays shutdown by x seconds.

Ex: #shutdown          -h           now #shutdown          -r            now #reboot #shutdown         

  • -h           120          Delay the shutdown by 2 minutes.


powers down the system.

------>To turn off the system #shutdown now (or)        # halt


works the same as the halt cmd.

------>To check the current run level   # runlevel (or) #who –r ------>To change run level 3                                 #init 3

In-depth understanding of Linux click on

About Author


Author Bio

TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills .