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
Know the steps of the boot
The boot is a chain. When it breaks, the last step you see tells you where to look.
- Firmware (UEFI or BIOS) tests the hardware and starts the boot loader.
- GRUB 2 shows the menu and loads the kernel and the initramfs.
- The kernel starts the hardware drivers and runs the initramfs.
- The initramfs (made by
dracut) finds the root file system (LVM, RAID, encryption) and mounts it on/sysroot. - systemd (PID 1) starts all units of the default target: file systems from fstab, network, services.
- 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 | headKnow the targets
A target is a system state: a group of units that run together.
| Target | What runs |
|---|---|
graphical.target | Everything + the desktop login |
multi-user.target | Everything for a server, text login, network |
rescue.target | A root shell with the base system, local file systems mounted, no network |
emergency.target | A root shell with only the root file system, read-only |
poweroff.target, reboot.target | Shut down / reboot |
systemctl get-default
multi-user.target
systemctl set-default graphical.target
systemctl isolate multi-user.target
systemctl list-dependencies multi-user.target | headset-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.
Boot one time into another target
At the GRUB menu you can add a kernel option for this boot only: systemd.unit=TARGET.
- Reboot. In the GRUB menu, select the entry and press
e. - Go to the line that starts with
linuxand add at the end:systemd.unit=rescue.target(oremergency.target, ormulti-user.target). - Press
Ctrl+Xto boot.
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.
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_64The 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| File | Meaning |
|---|---|
/etc/default/grub | Main settings: timeout, default options |
/boot/loader/entries/*.conf | One file per kernel (Boot Loader Specification) |
/boot/grub2/grub.cfg | The 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.
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 maintenancejournalctl -xb | grep -i -A3 'failed'
mount -o remount,rw /
vim /etc/fstab
systemctl daemon-reload
mount -a
systemctl defaultOp het werk
Prevent it: after every fstab change run mount -a and findmnt --verify before you reboot. For extra disks, add nofail.
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.
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
exitgrub2-install is for BIOS machines. On UEFI machines, reinstall the packages instead: dnf reinstall grub2-efi-x64 shim-x64.