Skip to main content

Boot process in linux






 Boot Process (RHEL7 & 6)

Booting is the process of to load OS from computers hard disk to primary memory (RAM).
                               
In RHEL 6
RHEL 7
BIOS
BIOS
MBR
MBR
GRUB
GRUB
KERNEL
KERNEL
INIT
SYSTEMD
RUNLEVELS
TARGETS

Step 1:  Power ON
When you press on power on button SMPS (switch mode power supply) will get an signal to power on, immediate after it PGS (Power on boot signal) will execute to get power to all components.

Step 2: POST 
(Power-on-Self-Test) is diagnostic testing sequence all the computer parts will diagnose there own.

Step 3: BIOS
(Basic Input Output System) BIOS is program which verifies all the attached components and identifies device booting order
Based on device order BIOS will first boot device, in this case we are considering as HDD as first boot device.

Step 4: MBR
(Master Boot Record) contains Boot Loader, Partition information and Magic Blocks or validation check
MBR Size 512bytes

1.       Boot loader – contains boot loader program which is 446 bytes in size.
2.       64 Bytes of partition information will be located under MBR, which will provide / redirects to actual /boot partition path to find GRUB2
3.       2bytes are magic bytes or validation check to identify errors

Step 5: GRUB
GRUB displays the splash screen, waits for few seconds, if you dont enter anything it loads the default kernal image as specified in the grub configuration file.
GRUB configuration file is in RHEL7 /boot/grub2/grub.cfg
GRUB configuration file is in RHEL6 /boot/grub/grub.cfg 
(Grand Unified Boot Loader) configuration file located in /boot/grub2/grub.cfg which actually points to initramfs is initial RAM disk, initial root file system will be mounted before real root file system.
GRUB has the knowledge of the file system(the old version of Linux Loader LILO didn’t understand filesystem).
Basically initramfs will load block device drivers such as SATA, RAID etc. 
The initramfs is bound to the kernel and the kernel mounts this initramfs as part of a two-stage boot process.

Step 6: KERNEL
KERNEL is heart of OS, it is bridge between application and hardware of computer, it is designed in c language.
When boot is processed, kernel will load. When kernel loading completes it immediately look forward to start processes / Services. It takes care of process mgmt, memory mgmt, resource mgmt, I/O etc
Name of kernel is Maipo 3.10 in RHEL7 & Santiago in RHEL 6
Kernel executes the /sbin/system in RHEL7 & /sbin/init program in RHEL6.
Types of kernel
1.Microkernel
2.Monolithic kernel

Comparison Chart:


Basis
Microkernel
Monolithic Kernel
Basic
In microkernel user services and kernel, services are kept in separate address space.
In monolithic kernel, both user services and kernel services are kept in the same address space.
Size
Microkernel are smaller in size.
Monolithic kernel is larger than microkernel.
Execution
Slow execution.
Fast execution.
Example
Windows NT, Symbian, Mac OS
Linux,  UNIX, Microsoft Windows (95,98,Me), Solaris, AIX, HP-UX, DOS

Step 7 :  Starting Systemd the first system process
                Faster bootup times since daemons start in parallel.
As we know before systemd there is no process / service exists. Systemd will be started by a system call fork( ); fork system call have an option to specify PID, that why systemd always hold PID 1.
As there is no sequence to start processes / Services, based on default.target will start.
Services with system are named something.service
Such as

For example, To enable a service in RHEL7
                #systemctl enable mariadb.service
Then a symbolic link is created from
/etc/system/system/multi-user.target.wants/mariadb.service
That points to
/usr/lib/systemd/system/mariadb.service

Step 8 : Targets
                To find which target belongs to which number
                                #ls –l /usr/lib/systemd/system/runlevel0.target
#ls –l /usr/lib/systemd/system/runlevel1.target
                                                                -------------------------
#ls –l /usr/lib/systemd/system/runlevel6.target

                                Which shows result as:
                                                lrwxrwxrwx           runlevel0.target ----> poweroff.target
lrwxrwxrwx           runlevel1.target ----> rescue.target
                                                                -------------------------
lrwxrwxrwx           runlevel6.target ----> restart.target

Targets:

RHEL6
RHEL7
#ls –l /etc/inittab
#ls –l /etc/systemd/system

default.target
graphical.target.wants
multi-user.target.wants
display-manager.service
firewalld.service

runlevel0 ----- poweroff
runlevel0.target --- poweroff.target
runlevel1 ----  single user mode
runlevel1.target --- rescue.target
        setup a rescue shell
single user mode
runlevel2 --- multi-user without NFS
runlevel2.target ---multi-user.target
non-graphical, user-defined runlevel
runlevel3 ----- multi-user with CLI(networking)
runlevel 3.target ---multi-user.target
text-console only
runlevel4--- Not used/user-defined
runlevel 4.target --- multi-user.target
non-graphical, user-defined runlevel
runlevel5 ----- GUI(X11)
runlevel 5.target ---graphical.target
graphical mode
runlevel6  ------ restart
runlevel 6.target --- reboot.target
restarts system



                                #systemctl set-default <tab>
                                               
                                                reboot.target         printer.target         bluetooth.target
                                                rescue.target         shutdown.target   sleep.target
                                                initrd.target           sound.target          multi-user.target
                                                network.target      suspend.target      default.target       
                                                runevel0.target     runlevel6.target    final.target

                                                graphical.target    umount.target      nfs.target

Step 9: User Interface (UI) 
Once that’s done, the “Wants” entry tells systemd to start the display-manager.service service(/etc/systemd/system/display-manager.service), which runs the GNOME display manager.
Your User interface start and prompt you for credential to login.

Below are the commands to know time of booting process taken:

[root@server ~]# systemd-analyze time
Startup finished in 1.895s (kernel) + 2.622s (initrd) + 20.402s (userspace) = 24.919s

[root@server ~]# systemd-analyze blame
6.850s firewalld.service
5.714s mariadb.service
5.509s tuned.service
5.350s plymouth-quit-wait.service


.








Comments

Popular posts from this blog

sed

Sed Command in Linux/Unix with examples SED command in UNIX is stands for stream editor and it can perform lot’s of function on file like, searching, find and replace, insertion or deletion. Though most common use of SED command in UNIX is for substitution or for find and replace. By using SED you can edit files even without opening it, which is much quicker way to find and replace something in file, than first opening that file in VI Editor and then changing it. o     SED is a powerful text stream editor. Can do insertion, deletion, search and replace(substitution). o     SED command in unix supports regular expression which allows it perform complex pattern matching. Syntax: sed OPTIONS... [SCRIPT] [INPUTFILE...] Example: Consider the below text file as an input. $cat > geekfile.txt unix is great os. unix is opensource. unix is free os. learn operating system. unixlinux which one you choose. unix is easy to learn.unix ...

initramfs" file is deleted or corrupted on your RHEL or CentOS 7

Initrd/Initramfs image provides the capability to load a RAM disk by the boot loader. This RAM disk can then be mounted as the root filesystem and programs can be run from it. Afterwards, a new root file system can be mounted from a different device. The previous root filesystem which was mounted from initrd/initramfs is then moved to a directory and can be subsequently unmounted. Their are chances that either you might have accidentally deleted "initramfs" file from the /boot partition or it is corrupted due to some reason.  Then boot process will get interrupted and you will see below error: error: file '/initramfs-3.10.0-957.el7.x86_64.img' not found. Good news is you can still recover this "initramfs" by following below steps: Step 1 :  Mount RHEL or CentOS 7 ISO image on your physical server and boot from it. In case you are using HPE Prolient server you can mount this ISO image on iLO, if this is virtual environment then mount it accordingly and reboot...

nw commands

troubleshoot commands in Linux.   1. ifconfig ifconfig (interface configurator) command   is use to initialize an interface, assign IP  Address to interface and enable or disable  interface on demand. With this command  you can view IP Address and Hardware / MAC   address assign to interface and also MTU (Maximum transmission unit) size. # ifconfig   eth0       Link encap:EthernetHWaddr 00:0C:29:28:FD:4C inet addr:192.168.50.2   Bcast:192.168.50.255   Mask:255.255.255.0           inet6 addr: fe80::20c:29ff:fe28:fd4c/64 Scope:Link           UP BROADCAST RUNNING MULTICAST   MTU:1500   Metric:1           RX packets:6093 errors:0 dropped:0 overruns:0 frame:0  ...
# # #