All technological notes.
Ends With:
bootloader (GRUB2).Hardware Components:
Firmware:
UEFI (Unified Extensible Firmware Interface):
GUID Partition Table (GPT), which offers a more flexible solution with no size constrainsBIOS (Basic Input/Output System):
Master Boot Record(MBR) system, which limits disk size to 2TBPower-On Self-Test (POST):
bootable devices (e.g., HDD, SSD, USB, PXE network boot).Bootloader:
bootloader into memory from the selected boot device
UEFI Configuration Files:
/boot/efi/EFI/NVRAM (Non-Volatile RAM) for boot options.Boot Order Settings:
BIOS/UEFI firmware interface.GRUB Bootloader Pointer:
UEFI systems: GRUB resides in the EFI system partitionBIOS systems: GRUB is located in the Master Boot Record (MBR) of the bootable disk.
/boot/efi/EFI/redhat/.BIOS Settings:
CMOS).Del, F2, or Esc during boot).bootloader (GRUB2) by the BIOS/UEFI firmware.Linux kernel and the initial RAM disk (initramfs) into memory and transferring control to the kernel.GRand Unified Bootloader (GRUB 2)
GRUB2 Bootloader:
EFI system partition (for UEFI) or the Master Boot Record (for legacy BIOS).Initramfs(initial ram file system):
Bootloader:
GRUB2 is loaded into memory by the BIOS/UEFI firmware.grub.cfg) and displays a menu with available boot options.Kernel and Initramfs:
vmlinuz-*) into memory.initramfs (initramfs-*) into memory to initialize hardware and mount the root filesystem.grub.cfg
/boot/efi/EFI/redhat/grub.cfg/boot/grub2/grub.cfg/etc/default/grub
GRUB optionsGRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=1G-4G:192M,4G-64G:256M,64G-:512M resume=/dev/mapper/rhel-swap rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
GRUB_TIMEOUT: Time in seconds before the default entry boots.GRUB_DEFAULT: Default boot entry (0-based index or entry name).GRUB_CMDLINE_LINUX: Additional kernel parameters.
/etc/grub.d/
/etc/default/grubgrub-mkconfig command runs these scripts to generate actual GRUB configuration.Don’t manually edit /boot/grub2/grub.cfg / /boot/efi/EFI/redhat/grub.cfg.
/etc/default/grub./etc/grub.d.| CMD | DECS |
|---|---|
grub2-install --version |
Displays the GRUB2 version installed on the system. |
grub2-install /dev/path |
Installing GRUB2 Bootloader |
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg |
Generates or updates the grub.cfg file |
grub2-editenv list |
View GRUB Environment Variables |
grub2-set-default 1 |
Sets the default boot entry by index or name. |
grub2-editenv - unset menu_auto_hide |
Disable GRUB menu auto-hide function |
init (or its modern equivalent, systemd) process is executed.vmlinuz):
initramfs):
GRUB2, these parameters configure kernel behavior during initialization.root=/dev/sda1, ro, quiet.kernel image (vmlinuz) decompresses itself and initializes core subsystems, including:
initramfs:
initramfs is mounted as a temporary root filesystem.root=/dev/sda1).init/systemd:
/sbin/init or /lib/systemd/systemd, transitioning control to user space.Kernel Image:
/boot/vmlinuz-<version>Initial RAM Disk:
/boot/initramfs-<version>.imgKernel Parameters:
/etc/default/grubGRUB_CMDLINE_LINUX="rhgb quiet"The systemd process (or its alternatives, like init in older systems) takes control, initializes user-space services, and sets up the operating environment.
/sbin/init or/lib/systemd/systemd(modern replacement).systemd:
Targets:
runlevels in SysVinit.multi-user.target: Multi-user CLI environment.graphical.target: Multi-user GUI environment.rescue.target: Single-user mode for system repair./usr/lib/systemd/system/ and /etc/systemd/system/.systemd Initialization:
systemd reads its configuration from /etc/systemd/system/ and determines the default target (configured in /etc/systemd/system/default.target)./etc/fstab are mounted.udev (for device management) and networkd (for network setup), are started./etc/systemd/system/default.target/usr/lib/systemd/system/: default system-provided units./etc/systemd/system/:custom overrides and additions./etc/fstab: defines filesystem mounts./etc/systemd/system.conf and /etc/systemd/user.conf: global systemd settings.Targets:
runlevels in SysVinit.
runlevels are replaced with systemd targets:| Runlevel | SysV Equivalent | systemd Target |
|---|---|---|
| 0 | Halt | poweroff.target |
| 1 | Single User Mode | rescue.target |
| 3 | Multi-User Mode | multi-user.target |
| 5 | Graphical Interface | graphical.target |
| 6 | Reboot | reboot.target |
dependencies:
CF: /etc/systemd/system/default.target
Common Comand
| CMD | DESC |
|---|---|
systemctl get-default |
Display the current target |
systemctl set-default graphical.target |
Set default target |
who -r |
Display the current run-level |
systemctl list-dependencies graphical.target | grep target
# graphical.target
# ● └─multi-user.target
# ● ├─basic.target
# ● │ ├─paths.target
# ● │ ├─slices.target
# ● │ ├─sockets.target
# ● │ ├─sysinit.target
# ● │ │ ├─cryptsetup.target
# ● │ │ ├─local-fs.target
# ● │ │ └─swap.target
# ● │ └─timers.target
# ● ├─getty.target
# ● ├─nfs-client.target
# ● │ └─remote-fs-pre.target
# ● └─remote-fs.target
# ● └─nfs-client.target
# ● └─remote-fs-pre.target
ls -al /lib/systemd/system/runlevel*
# lrwxrwxrwx. 1 root root 15 Nov 7 07:06 /lib/systemd/system/runlevel0.target -> poweroff.target
# lrwxrwxrwx. 1 root root 13 Nov 7 07:06 /lib/systemd/system/runlevel1.target -> rescue.target
# lrwxrwxrwx. 1 root root 17 Nov 7 07:06 /lib/systemd/system/runlevel2.target -> multi-user.target
# lrwxrwxrwx. 1 root root 17 Nov 7 07:06 /lib/systemd/system/runlevel3.target -> multi-user.target
# lrwxrwxrwx. 1 root root 17 Nov 7 07:06 /lib/systemd/system/runlevel4.target -> multi-user.target
# lrwxrwxrwx. 1 root root 16 Nov 7 07:06 /lib/systemd/system/runlevel5.target -> graphical.target
# lrwxrwxrwx. 1 root root 13 Nov 7 07:06 /lib/systemd/system/runlevel6.target -> reboot.target
| CMD | DESC |
|---|---|
journalctl -b |
Shows logs from the last boot |
journalctl -b -1 |
Shows logs from the previous boot |
journalctl -b -2 |
Shows logs from the boot before the previous boot |
e to edit the selected boot entry.single-user mode.linux16 or linuxefi) and contains the kernel path (e.g., /boot/vmlinuz).rd.break
rd.break parameter interrupts the boot process and gives access to an emergency shell before the root filesystem is mounted.init=/bin/shCtrl + X or F10 to boot with the modified parameters.# Remount the Root Filesystem as Read-Write
# need write access to edit the root user's password in the system's shadow file.
mount -o remount,rw /sysroot
# Switch to the sysroot Environment
# Change the root directory to /sysroot, enabling commands to work as if the system has booted normally.
chroot /sysroot
# Reset the Root Password
# updates the root password in /etc/shadow.
passwd
# Re-label the Filesystem (SELinux Contexts)
# Create an empty file to signal SELinux to relabel files during the next boot
# SELinux enforces security contexts, and any changes to the system require relabeling to ensure proper access controls.
touch /.autorelabel
# Exit and Reboot the System
# The system will boot normally, applying the SELinux relabeling and allowing access with the new root password.
exit
reboot
init=/bin/sh# Remount the file system as writeable
mount -o remount,rw /
# Reset the root password.
passwd
# To relabel all files on the next system boot
touch /.autorelabel
# Reboot the system
/usr/sbin/reboot -f
# change value
vi /etc/default/grub
# GRUB_TIMEOUT=10
# apply
grub2-mkconfig -o /boot/grub2/grub.cfg
# Generating grub configuration file ...
# Adding boot menu entry for UEFI Firmware Settings ...
# done
# on UEFI systems.
# grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
emergency
rescue
1
s
single
rd.break
# Make /sysroot appear as mounted on / using the chroot command:
chroot /sysroot
# Remount the root file system in read/write mode
mount -o remount,rw /
# change pwd
passwd
# Create a hidden file called .autorelabel to run SELinux relabeling on all files
touch /.autorelabel
# exit command to quit the chroot shell
exit
# restart the system and boot it to the default target.
reboot