Boot Process in RHEL 6 and 7.
This will explain about the boot process in RHEL 6 and 7.
You can see the difference between RHEL 6 and RHEL 7 boot process.
The boot process explain below.
Stage
|
RHEL 6
|
RHEL 7
|
Boot
|
·
Stand for Basic Input/Output System.
·
Once the server is powered on Mother Board
start executing the BIOS.
·
BIOS performs system integrity checks (POST).
·
Searches, loads and executes the boot loader
program.
·
It looks for boot loaded in mass storage by
using boot sequence or boot order.
·
Once the boot loader program is detected and
loaded into the primary memory (RAM), BIOS gives the control to it.
·
In simple terms BIOS loads and executes the
boot loader from MBR (Master Boot Recorder).
|
·
Stand for Basic Input/Output System.
·
Once the server is powered on Mother Board
start executing the BIOS.
·
BIOS performs system integrity checks (POST).
·
Searches, loads and executes the boot loader
program.
·
It looks for boot loaded in mass storage by
using boot sequence or boot order.
·
Once the boot loader program is detected and
loaded into the primary memory (RAM), BIOS gives the control to it.
·
In simple terms BIOS loads and executes the
boot loader from MBR (Master Boot Recorder).
|
MBR
|
·
Stand for Master Boot Recorder.
·
It is located in the 1st sector
(512 bytes) of the bootable disk. Typically /dev/sda.
·
MBR has tree components.
§
Primary Boot Loader information in 1st 446 bytes
§
Partition table information in next 64 bytes.
§
MBR validation check in the last 2 bytes.
·
It contains information about GRUB.
·
In simple terms MBR loads and executes the
GRUB Boot loader
|
·
Stand for Master Boot Recorder.
·
It is located in the 1st sector
(512 bytes) of the bootable disk. Typically /dev/sda.
·
MBR has tree components.
§
Primary Boot Loader information in 1st 446 bytes
§
Partition table information in next 64 bytes.
§
MBR validation check in the last 2 bytes.
·
It contains information about GRUB2.
·
In simple terms MBR loads and executes the
GRUB2 Boot loader
|
GRUB/GRUB2
|
·
Stand for Grand Unified Bootloader.
·
If multiple kernel images are installed in
server, you can choose which one to be executed.
·
GRUB displays a splash screen, waits for few
seconds, if you have not selected anything, it loads the default kernel image
as specified in the grub configuration file.
·
GRUB configuration file is
/boot/grub/grub.conf (/etc/grub.conf is soft link to this). The following is
sample grub.conf of RHEL 6
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux
(2.6.32-431.el6.x86_64)
root (hd0,0)
kernel
/vmlinuz-2.6.32-431.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rhgb
quiet
initrd
/initramfs-2.6.32-431.el6.x86_64.img
·
As you notice from the above info, it contains
kernel and initrd image.
·
In simple terms GRUB just loads and executes
Kernel and initrd images.
|
·
In RHEL7, GRUB2
will be used. And stands for Grand Unified Bootloader version 2.
·
Supports GPT, additional firmware types,
including BIOS, EFI and Open Firmware.
·
Ability to boot on various file systems
(xfs,ext4,ntfs,hfs+, raid, etc)
·
GRUB configuration file is /boot/grub2/grub.conf
(/etc/grub2.conf is soft link to this). /etc/grub.d/* and /etc/default/grub other
grub configuration files.The following is sample grub.conf of RHEL 7
### BEGIN /etc/grub.d/10_linux ###
menuentry 'Red Hat Enterprise Linux
Server, with Linux 3.10.0-123.el7.x86_64' --class red --class gnu-linux
--class gnu --class os --unrestricted $menuentry_id_option
'gnulinux-3.10.0-123.el7.x86_64-advanced-aa654ec4-5630-4e1e-90a3-c1363239ad09'
{
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod xfs
set root='hd0,msdos1'
if [ x$feature_platform_search_hint =
xy ]; then
search --no-floppy --fs-uuid
--set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1
--hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' bff6160f-575f-4962-a152-573f76669b74
else
search --no-floppy --fs-uuid
--set=root bff6160f-575f-4962-a152-573f76669b74
fi
linux16
/vmlinuz-3.10.0-123.el7.x86_64
root=UUID=aa654ec4-5630-4e1e-90a3-c1363239ad09 ro rd.lvm.lv=rhel/root
crashkernel=auto rd.lvm.lv=rhel/swap
vconsole.font=latarcyrheb-sun16 vconsole.keymap=us rhgb quiet
LANG=en_US.UTF-8
initrd16
/initramfs-3.10.0-123.el7.x86_64.img
}
·
As you notice from the above info, it contains
linux16 (kernel) and initrd16 (initramfs) image.
·
In simple terms GRUB2 just loads and executes
Kernel and initrd images.
|
Kernel
|
·
initrd stands for Initial RAM Disk.
·
Initrd is used by kernel as temporary root
file system until the kernel is booted and the real root file system is
mounted (ready-only format). It also contains necessary drivers compiled
inside, which helps it to access the hard drive partitions, and other
hardware.
·
Kernel re-mounts the root file system as
specified in the “root=” in grub.conf as read-write.
·
Kernel executes the /sbin/init program
·
Since init was the 1st program to
be executed by Linux kernel, it has the process id (PID) of 1.
·
In simple terms Kernel just executes init
program.
|
·
initrd stands for Initial RAM Disk. In RHEL 7,
initrd16 will be used.
·
Initrd16 is used by kernel as temporary root
file system until the kernel is booted and the real root file system is
mounted (ready-only format) on /sysroot. It also contains necessary drivers
compiled inside, which helps it to access the hard drive partitions, and
other hardware.
·
Kernel re-mounts the root file system as
specified in the “root=” in grub.conf as read-write.
·
Kernel executes the /usr/lib/systemd/systemd
·
Since systemd was the 1st program to be
executed by Linux kernel, it has the process id (PID) of 1.
·
In simple terms Kernel just executes systemd
program.
|
Init/Systemd
|
·
Looks at the /etc/inittab file to decide the
Linux run level.
·
Following are the available run levels.
§
0 –
halt
§
1 –
Single user mode
§
2 –
Multiuser, without NFS
§
3 - Full Multiuser Mode
§
4 –
unused
§
5 – X11
§
6 –
reboot
·
Init identified the default initlevel from
/etc/inittab and uses that to load all appropriate programs.
·
Execute ‘grep initdefault /etc/inittab’ on
your system to identify the default run level.
·
Typically you would set the default run level
to either 3 or 5.
·
In simple terms Init program executes the
programs under run level which is set as a default.
|
·
The run levels are called as “target”.
·
Looks for a default target, either passed in
from the kernel command line or configured on the system.
·
Based on default the target, it starts (and
stops) units. Units contains the services and its dependencies.
·
Generally /etc/systemd/system/default.target
is soft link and will be pointing to target.
·
Execute ‘systemctl get-default’ on your system
to identify the default target
·
Following
are the available targets.
§
Rescue.target
§
Multi-user.target
§
Graphical.target
·
Run levels and target comparison.
§
runlevel0.target -> poweroff.target
§
runlevel1.target -> rescue.target
§
runlevel2.target -> multi-user.target
§
runlevel3.target -> multi-user.target
§
runlevel4.target -> multi-user.target
§
runlevel5.target -> graphical.target
§
runlevel6.target -> reboot.target
·
Typically you would set the default target to
either multi-user.target or graphical.target.
·
Execute ‘systemctl set-default
graphical.target’ on your computer to change the default target.
·
In simple terms systemd program executes the
programs under target which is set as a default.
|
Runlevel/Target
|
·
When the Linux system is booting up, you might
see various services getting started. For example, it might say “starting
ssh ….. OK”. Those are the run level
programs, executed from the run level directory as defined by your run level.
·
Depending on your default init level setting,
the system will execute the programs from one of the following the
directories.
§
Run level 0 - /etc/rc.d/rc0.d/
§
Run level 1 - /etc/rc.d/rc1.d/
§
Run level 2 - /etc/rc.d/rc2.d/
§
Run level 3 - /etc/rc.d/rc3.d/
§
Run level 4 - /etc/rc.d/rc4.d/
§
Run level 5 - /etc/rc.d/rc5.d/
§
Run level 6 - /etc/rc.d/rc6.d/
·
Please note that there are also symbolic links
available for these directory under /etc directly. So /etc/rc0.d is linked to
/etc/rc.d/rc0.d.
·
Under the /etc/rc.d/rc*.d/ directories, you
would see scripts that are start with S and K.
·
The scripts start with S are used during
startup. S for startup.
·
The scripts start with K are used during
shutdown. K for kill.
·
There are numbers right next to S and K in the
scripts names. Those are the sequence number in which the scripts should be
started or killed.
·
For example, S12rsyslog is to start the
rsyslog deamon, which has the sequence number of 12. S55sshd is to start the
ssh deamon, which has the sequence number 55. So, rsyslog will be started
before the sshd.
|
·
The systemd start all the system services
based on the default target.
·
If the default target pointing to “graphical.target”.
Typically the graphical.target file includes these lines.
# cat /usr/lib/systemd/system/graphical.target
Requires=multi-user.target
After=multi-user.target
Wants=display-manager.service
·
This tells systemd to start everything in the
multi-user.target before starting the graphical target. 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 (/usr/sbin/gdm).
·
The multi-user.target file includes these.
# cat /usr/lib/systemd/system/multi-user.target
Requires=basic.target
·
This tells systemd to start everything in the /usr/lib/systemd/system/basic.target
target before starting the other multi-user services. After that, for the
multi-user.target, all units (services, targets, etc.) in the /etc/systemd/system/multi-user.target.wants
and /usr/lib/systemd/system/multi-user.target.wants directories are
started.
·
When you enable a service, a symbolic link is
placed in the /etc/systemd/system/multi-user.target.wants
directory. That directory is where you will find links to most of the
services you think of as starting in multi-user mode (printing, cron,
auditing, SSH, and so on).
·
Typical multi-user.target.wants
directory contains the soft links of services and/or targets from /usr/lib/systemd/system/*.
·
The basic.target file includes these.
# cat /usr/lib/systemd/system/basic.target
Requires=sysinit.target
·
This points systemd to the /usr/lib/systemd/system/sysinit.target,
which must start before the basic.target
can continue. The basic.target
target file starts the firewalld and microcode services from the /etc/systemd/system/basic.target.wants
directory and services for SELinux, kernel messages, and loading modules from
the /usr/lib/systemd/system/basic.target.wants
directory.
·
The sysinit.target file includes these.
# cat /usr/lib/systemd/system/sysinit.target
Wants=local-fs.target swap.target
·
Besides mounting file systems and enabling
swap devices, the sysinit.target starts targets, services, and mounts based
on units contained in the /usr/lib/systemd/system/sysinit.target.wants
directory. These units enable logging, set kernel options, start the udevd
daemon to detect hardware, and allow file system decryption, among other
things.
·
The /etc/systemd/system/sysinit.target.wants
directory contains services that start iSCSI, multipath, LVM monitoring and
RAID services.
·
The local-fs.target file includes these.
# cat /usr/lib/systemd/system/local-fs.target
After=local-fs-pre.target
·
There are no services associated with the
local-fs-pre.target target (you could add some to a "wants"
directory if you like). However, units in the /usr/lib/systemd/system/local-fs.target.wants
directory import the network configuration from the initramfs, run a file
system check (fsck) on the root file system when necessary, and remounting
the root file system (and special kernel file systems) based on the contents
of the /etc/fstab file.
·
To see what services are associated with a particular
target. Execute “systemctl list-dependencies multi-user.target”
|
No comments:
Post a Comment