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 17Naam in het boek: Managing and Understanding the Boot Procedure

Control what the system boots into

Two things decide how a RHEL system starts: the GRUB 2 boot loader (which kernel, which kernel options) and the systemd target (which services). This chapter shows how to work with targets, set the default target, switch targets, and change the boot options with GRUB 2.

  • 11 Lessen
  • 8 Commando's
  • 2 Labs

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

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

Examendoelen in dit hoofdstuk

  • Een systeem altijd in een gekozen target laten opstarten
  • De bootloader van het systeem aanpassen

17.1

Understand systemd targets

A target is a group of units that brings the system to a state. At boot, systemd starts the default target and everything it needs.

TargetUse
graphical.targetDesktop login (includes multi-user)
multi-user.targetNormal server, text login, network, services
rescue.targetRepair: single user, root login, few services, file systems mounted
emergency.targetMinimal: root file system read-only, almost nothing started
poweroff.target, reboot.targetTurn off / restart
systemctl get-default
systemctl list-units -t target

17.2

Look inside a target

A target unit file has little content. The real list of services comes from wants: links in TARGET.target.wants/ folders.

systemctl cat multi-user.target
ls /etc/systemd/system/multi-user.target.wants/
systemctl list-dependencies multi-user.target | head -20
/usr/lib/systemd/system/multi-user.target
[Unit]
Description=Multi-User System
Documentation=man:systemd.special(7)
Requires=basic.target
Conflicts=rescue.service rescue.target
After=basic.target rescue.service rescue.target
AllowIsolate=yes

Notitie

AllowIsolate=yes means you can switch to this target with isolate. Only targets that are a full system state have it.

17.3

Understand wants

systemctl enable does nothing more than create a link in the .wants folder of the target named in the [Install] section (WantedBy=).

systemctl enable httpd
Created symlink '/etc/systemd/system/multi-user.target.wants/httpd.service' → '/usr/lib/systemd/system/httpd.service'.
systemctl disable httpd
Removed '/etc/systemd/system/multi-user.target.wants/httpd.service'.

17.4

Switch to another target now

systemctl isolate TARGET starts that target and stops everything that is not part of it. Use it to go to text mode or rescue mode without a reboot.

systemctl isolate multi-user.target
systemctl isolate graphical.target
systemctl isolate rescue.target
systemctl list-units -t target --state=active

Let op

Isolating rescue.target stops the network and SSH. Only do it on the console.

17.5

Set the default target

The default target is a link /etc/systemd/system/default.target. set-default changes it.

systemctl get-default
graphical.target
systemctl set-default multi-user.target
Removed '/etc/systemd/system/default.target'.
Created symlink '/etc/systemd/system/default.target' → '/usr/lib/systemd/system/multi-user.target'.

Examentip

"The system must boot into text mode" = systemctl set-default multi-user.target. Check after a reboot with systemctl get-default.

17.6

Understand GRUB 2

GRUB 2 is the first program after the firmware (BIOS or UEFI). It shows the boot menu, loads the kernel and the initramfs, and passes the kernel command line.

  • RHEL uses BLS (Boot Loader Specification): one small file per kernel in /boot/loader/entries/.
  • The main config grub.cfg is generated — do not edit it by hand.
  • At the boot menu, press e to edit an entry for one boot only, Ctrl+X to boot it.
ls /boot/loader/entries/
cat /boot/loader/entries/*$(uname -r).conf
cat /proc/cmdline

17.7

Know the GRUB 2 configuration files

You change settings in /etc/default/grub (defaults for all kernels) or with grubby (per kernel). grub2-mkconfig writes the generated config.

FilePurpose
/etc/default/grubYour settings: timeout, default kernel options (GRUB_CMDLINE_LINUX)
/etc/grub.d/Scripts that build grub.cfg
/boot/grub2/grub.cfgGenerated config (BIOS and UEFI on RHEL 9+/10)
/boot/loader/entries/*.confOne entry per kernel (BLS)
/boot/efi/EFI/redhat/grub.cfgOn UEFI: small stub that points to /boot/grub2/grub.cfg
/etc/default/grub
GRUB_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"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true

17.8

Change the default boot options

Add or remove kernel options for all kernels with grubby, or edit /etc/default/grub and regenerate the config.

  1. Change options with grubby (applies to the BLS entries right away).
    grubby --update-kernel=ALL --args="console=ttyS0"
    grubby --update-kernel=ALL --remove-args="rhgb quiet"
    grubby --info=DEFAULT
  2. Or change the timeout or the default command line in /etc/default/grub and regenerate. When you changed GRUB_CMDLINE_LINUX, add --update-bls-cmdline, or the kernel entries keep their old options.
    vim /etc/default/grub
    grub2-mkconfig -o /boot/grub2/grub.cfg
    grub2-mkconfig -o /boot/grub2/grub.cfg --update-bls-cmdline
  3. Choose the default kernel.
    grubby --default-kernel
    grubby --set-default /boot/vmlinuz-6.12.0-55.el10.x86_64

Examentip

Tasks like "remove rhgb and quiet" or "set the boot timeout to 10 seconds" need GRUB changes. After /etc/default/grub changes, always run grub2-mkconfig -o /boot/grub2/grub.cfg (with --update-bls-cmdline for command line changes) — or use grubby, which changes the entries directly. Check with cat /proc/cmdline after a reboot.

Op het werk

Protect the boot menu with a password so nobody at the console can edit kernel options: grub2-setpassword.

17.9

Remember the main points

The most important facts of this chapter, in short.

17.10

Learn the key terms

The words of this chapter in simple English.

TermMeaning
TargetA group of units for one system state.
Default targetThe target the system boots into.
IsolateStop everything not needed and start a target.
WantsA soft dependency: start this too if you can.
GRUB 2The boot loader of RHEL.
BLSBoot Loader Specification: one small file per boot entry.
Kernel argumentAn option given to the kernel at boot, like quiet or rd.break.
grubbyA tool to change boot entries and kernel arguments.

17.11

Check what you learned

Think about the answer first, then open it.

1How do you make the system always boot into text mode?
2How do you switch to the desktop now, without a reboot?
3Which target is the smallest one that still mounts the file systems?

rescue.target (emergency.target mounts only / read-only).

4How do you remove rhgb quiet from all kernels?
5How do you change the GRUB timeout to 10 seconds?

Set GRUB_TIMEOUT=10 in /etc/default/grub, then grub2-mkconfig -o /boot/grub2/grub.cfg.

6How do you add a kernel option for only one boot?

Press e at the GRUB menu, add it to the linux line, press Ctrl+X.

7Which command shows the current default kernel?
8Where are the boot entries of RHEL 10?

In /boot/loader/entries/ (BLS files).

Oefenen

Alle commando's in dit hoofdstuk