Boot Modes & Recovery
New Boot Process (CentOS/RHEL 7 and above):
- systemd manages boot sequence
- backward compatible with SysV init scripts from previous versions
BIOS - Basic Input/Output System (firmware interface)
POST - Power-On-Self-Test started
- MBR - Master Boot Record
- information saved in first sector of hard disk that indicates where the GRUB2 is located so it can be loaded in RAM
- GRUB2 - Grant Unified Boot Loader v2 - loads linux kernel
- information saved in first sector of hard disk that indicates where the GRUB2 is located so it can be loaded in RAM
/boot/grub2/grub.cfg
- Kernel - Core of the operating system - loads required drivers from initrd.img starts first OS process
systemd
- Systemd = System Daemon (PID #1) then starts all required processes
read /etc/systemd/system/default.target to bring system to run level (7 run levels 0-6)
How to Reboot / Shutdown
|
systemctl poweroff |
stops all services, unmounts file systems, powers off system |
|
poweroff |
|
|
systemctl reboot |
all of the above plus reboot |
|
reboot |
Select systemd target
- 0-6 run levels now referred to as targets
- important targets:
- graphical.target - system supports multiple users, graphical and text based logins
- multi-user.target - system supports multiple users, text based logins only
- rescue.target - sulogin prompt, basic system initialisation completed
- emergency.target - sulogin prompt, initramfs pivot complete and system root mounted on / read only
- a target can be part of another target (graphical.target includes mult-user.target)
|
systemctl get-default |
check current target |
|
who -r |
run level |
|
systemctl list-dependencies graphical.target | grep target |
list target dependencies |
|
ls -l /lib/systemd/system/runlevel* |
list run levels |
|
systemctl set-default graphical.target |
set default target |
Recover Root Password (RHEL 9)
|
Reboot |
|
|
Press esc to get to grub |
|
|
Find line beginning with Linux, add " rd.break" to the end |
RHEL 9 boot into emergency recovery mode |
|
Find line beginning with Linux, add "init=/bin/bash" to the end |
RHEL 10 boot into emergency recovery mode |
|
Press Ctrl X |
start boot using the modified settings |
|
mount -o remount,rw /sysroot |
RHEL 9 remount the root filesystem as read-write to allow changes |
|
mount -o remount,rw / |
RHEL 10 remount the root filesystem as read-write to allow changes |
|
chroot /sysroot |
change root to /sysroot (RHEL OS) |
|
passwd |
|
|
Enter your new password |
|
|
touch /.autorelabel |
Force SELinux to relabel files on next boot |
|
exit |
RHEL 9 exit back to emergency shell |
|
mount -o remount,ro / |
RHEL 10 reboot cleanly |
|
exit |
exit to boot |
Repair Filesystem Corruption
Common errors
|
Corrupt file system |
systemd attempts to repair file system |
|
nonexistent device/UUID in /etc/fstab |
if device remains unavailable, go to emergency shell |
|
nonexistent mount point in /etc/fstab |
go to emergency shell |
|
incorrect mount option in /etc/fstab |
go to emergency shell |
Emergency target can diagnose and fix the issue, because no file systems are mounted before emergency shell is displayed
|
systemctl daemon-reload |
when using emergency shell, remember to run this after editing /etc/fstab |