Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

Hoofdstuk 12Naam in de cursus: Controlling and Troubleshooting the Boot Process

Control the boot and fix boot problems

When a server does not come up after a change, you must know the steps of the boot, choose what the system boots into, change kernel options, and get a repair shell. This chapter covers the boot steps, systemd targets, GRUB 2 and the rescue and emergency modes.

  • 7 Lessen
  • 15 Commando's
  • 3 Labs

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

Vaardigheden in dit hoofdstuk

  • Het opstarttarget kiezen en opstartproblemen oplossen

12.1

Know the steps of the boot

The boot is a chain. When it breaks, the last step you see tells you where to look.

  1. Firmware (UEFI or BIOS) tests the hardware and starts the boot loader.
  2. GRUB 2 shows the menu and loads the kernel and the initramfs.
  3. The kernel starts the hardware drivers and runs the initramfs.
  4. The initramfs (made by dracut) finds the root file system (LVM, RAID, encryption) and mounts it on /sysroot.
  5. systemd (PID 1) starts all units of the default target: file systems from fstab, network, services.
  6. A login prompt (text or graphical) appears.
systemd-analyze
Startup finished in 1.215s (kernel) + 2.810s (initrd) + 8.402s (userspace) = 12.428s
systemd-analyze blame | head -5
journalctl -b -o short-monotonic | head

12.2

Know the targets

A target is a system state: a group of units that run together.

TargetWhat runs
graphical.targetEverything + the desktop login
multi-user.targetEverything for a server, text login, network
rescue.targetA root shell with the base system, local file systems mounted, no network
emergency.targetA root shell with only the root file system, read-only
poweroff.target, reboot.targetShut down / reboot
systemctl get-default
multi-user.target
systemctl set-default graphical.target
systemctl isolate multi-user.target
systemctl list-dependencies multi-user.target | head
  • set-default = for every boot. isolate = switch now, stop everything that is not part of the new target.

Examentip

"The system must boot into text mode by default" → systemctl set-default multi-user.target. Check with systemctl get-default.

12.3

Boot one time into another target

At the GRUB menu you can add a kernel option for this boot only: systemd.unit=TARGET.

  1. Reboot. In the GRUB menu, select the entry and press e.
  2. Go to the line that starts with linux and add at the end: systemd.unit=rescue.target (or emergency.target, or multi-user.target).
  3. Press Ctrl+X to boot.
systemctl reboot
systemctl rescue

Notitie

rescue.target and emergency.target ask for the root password. If root has no password (locked), they can not be used — then use the method of Recover root access.

12.4

Change kernel options for good

grubby changes the kernel options of the boot entries directly. It is the easy and safe way on RHEL.

grubby --default-kernel
/boot/vmlinuz-6.12.0-55.9.1.el10_0.x86_64
grubby --info=DEFAULT
grubby --update-kernel=ALL --args="quiet"
grubby --update-kernel=ALL --remove-args="rhgb"
grubby --info=ALL | grep -E '^(kernel|args)'
grubby --set-default=/boot/vmlinuz-6.12.0-55.9.1.el10_0.x86_64

The other way: change GRUB_CMDLINE_LINUX in /etc/default/grub, then write the config again:

vim /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg --update-bls-cmdline
FileMeaning
/etc/default/grubMain settings: timeout, default options
/boot/loader/entries/*.confOne file per kernel (Boot Loader Specification)
/boot/grub2/grub.cfgThe generated config — do not edit by hand

Onthoud

Without --update-bls-cmdline, grub2-mkconfig does not change the options of the existing kernel entries. grubby always changes them.

12.5

Repair a wrong fstab line

A wrong line in /etc/fstab (wrong UUID, missing disk, typo) stops the boot in emergency mode. Make root writable, fix the file, go on.

You are in emergency mode. After logging in, type "journalctl -xb" to view
system logs, "systemctl reboot" to reboot, "systemctl default" or "exit"
to boot into default mode.
Give root password for maintenance
journalctl -xb | grep -i -A3 'failed'
mount -o remount,rw /
vim /etc/fstab
systemctl daemon-reload
mount -a
systemctl default

Op het werk

Prevent it: after every fstab change run mount -a and findmnt --verify before you reboot. For extra disks, add nofail.

12.6

Use the debug shell for hard cases

When the boot hangs, the debug shell gives a root shell on TTY9 early in the boot — no password. Use it only for repair, then turn it off.

systemctl enable debug-shell.service
grubby --update-kernel=ALL --args="systemd.debug-shell=1"
systemctl list-jobs
systemctl disable debug-shell.service
grubby --update-kernel=ALL --remove-args="systemd.debug-shell=1"

Press Ctrl+Alt+F9 during the boot to get the shell. systemctl list-jobs shows which unit the boot waits for.

Let op

The debug shell is a root shell without password. Never leave it on.

12.7

Repair the boot loader and the initramfs

When GRUB or the initramfs is broken, boot from the RHEL installation ISO in rescue mode, enter the installed system, and rebuild them.

chroot /mnt/sysroot
dracut -f --regenerate-all
grub2-install /dev/vda
grub2-mkconfig -o /boot/grub2/grub.cfg
exit

grub2-install is for BIOS machines. On UEFI machines, reinstall the packages instead: dnf reinstall grub2-efi-x64 shim-x64.

More: Fix a system that does not boot.

Oefenen

Alle commando's in dit hoofdstuk