Skip to main content

Linux boot process

 


Every system administrator needs to understand the boot process on the OS in order to troubleshoot effectively.


>BIOS- basic input output setting(firmware interface)

POST: power on self test


>MBR is loaded: master boot record


Information saved in the first sector of the hard disk that indicates where GRUB2 is located so it can be loaded in the computer RAM.


>GRUB2 is loaded: grand unified boot loader v2. loads the linux kernel: /boot/grub2/grub.cfg


> Kernel is loaded: core of the OS.

 loads the required drivers from the initrd.img, starts the first OS process.


> systemd process is started: System daemon (PID=1)

It then starts all the required processes. It reads /etc/systemd/system/default.target to bring the system to run-level. Total 7 run levels we have. 


*************************************


How to reboot/shutdown:


power off the system:


# systemctl poweroff = stops all the running services, unmount all the filesystems. and then power off the system.


# systemctl reboot = stops all the running services, unmounts all the filesystems, and then reboots the system.


or we can use the shorter versions of these commands:


#shutdown: poweroff the server

#reboot: reboot the system.

#poweroff: poweroff the system.


**************************************



Selecting the Systemd Target:


>systemd is the first linux process which decides at which run level the operating system needs to be in. 


These run levels are now referred to as targets.

following are the most important targets:


>graphical target: system supports multiple users, graphical and text based logins

>multi-user target :system supports multiple user text based logins only 

>rescue target: sulogin prompt, bash system initialization completed .

>emergency target :sulogin prompt initramfs pivot complete and system root mounted on /read only



To check the current target or run level

#systemctl get-default



To check the current run level

#who-r



A target can be the part of another target eg the graphical target includes multi- user target, which in turn depends on basic taget and others


we can view these dependencies with the following command .

#systemctl  list-dependencies  graphical.target | grep target



you can display the new run levels/target by issuing the following command:

#ls  -l  /lib/systemd/system/runlevel*



how to change the run level /target ?

#systemctl set-default graphical.target


*************************************


How to recover the root password?

steps given below:


• Restart your computer.


• Edit the grub


•change password


•reboot


***********************************


Repair Filesystem Corruption


Filesystem corruption can occur when you either make mistakes in /etc configuration files. 

or filesystem become corrupted at the disk level.


In either of the above cases the systemd will not be able to boot the system in the defined

target and bring the system in the emergency mode.


*****************************************


The following are the problems related to filesystem and its results:


>Corrupt filesystem: systemd attempts to repair the filesystem. If the problem is too sever for the automatic fix, the system drops the user to an emergency shell.


> Non consistent device or UUID referrenced in /etc/fstab: systemd waits for set amount of time, waiting for the device to become available. If the device does not become available, the system drops the user to an emergency shell after the time out


> Non existent mount point in /etc/fstab :system drops the user to an emergency shell.


>Incorrect mount options specified in /etc/fstab: system drops the user to an emergency shell.


*************************************


In any case administrators can use the emergency target to diagnose and fix the issue. because no file systems are mounted before the emergency shell is displayed.


When using the emergency shell to fix the filesystem issues, do not forget to run systemctl daemon-reload after editing /etc/fstab. Without this reload. systemd may continue using the old version.


Comments

Popular posts from this blog

Linux basic commands

 Linux basic commands: du  -sh  *  |  sort  -h  -r   |  head  -n  40  :    list out first 40 files in the directory that are taking more space in the directory.  cd : change directory Is-l listing the items in long listing format  pwd : print working directory Is-I format: type :no of links:owner : group:size :month :day :time :name cd/: go to/directory whoami: tells us by which username we are logged in. touch jerry: creates the file named jerry in present working directory. cp jerry lex: copy the content of jerry file and paste it to lex file. vi text1: creates the file text1 and open it in vi editor mkdir superman: creates the directory called superman mkdir abc def  : creates 2 folder in one command. touch filename wont work in /etc/ folder if logged in by normal account. man cp: shows manual for cp command. echo "india is my country"> file1 puts the text in file1. rm filename: remove the filename  mv lex luther renames the file from lex to luther  mv luther /h

patching tasks

 Patching a Linux system is a critical task to ensure that the system remains secure, stable, and up-to-date with the latest features and fixes. Here’s a comprehensive guide to the tasks involved in Linux patching: 1. Pre-Patching Preparation Backup System : Ensure you have a full system backup, including critical data, configuration files, and applications. Test the backup to verify its integrity. Check Disk Space : Verify that you have enough disk space, particularly on /var , /tmp , and /boot partitions. Review Current Patch Level : Determine the current patch level and installed packages using package management tools like yum , apt , dpkg , or rpm . Check System Logs : Review system logs to identify any issues that might affect the patching process. Test in a Staging Environment : If possible, apply patches in a staging environment that mirrors production to identify potential issues. Notify Stakeholders : Inform stakeholders about the scheduled maintenance window and expected do