Managing Boot Procedure
Theory Questions
1. Define a system “want” efficiently.
- Command(s):
systemctl enable <unit>
* **Why:** Enables a unit by creating a symbolic link in the `.target.wants` directory, defining a soft dependency where systemd attempts to start the unit when the target loads.
* **Gotchas:** Avoid manually creating symlinks; using `systemctl enable` ensures proper tracking, systemd reloads, and clean uninstallation.
* **Verify:**
```bash
systemctl is-enabled <unit>
2. Identify the normal default target for servers.
- Command(s):
systemctl get-default
- Why: Displays the active default boot target. RHEL production servers typically boot into
multi-user.target(non-graphical multi-user CLI environment). - Gotchas: Confusing
multi-user.target(standard CLI environment) withgraphical.target(GUI environment with X11/Wayland). - Verify: Output should display:
multi-user.target
3. Identify valid and invalid Systemd targets.
- Command(s):
systemctl list-unit-files --type=target
- Why: Displays all available target unit files on the system alongside their configuration state (
enabled,disabled,static, ormasked). - Gotchas: Units marked as
staticlack an[Install]section and cannot be directly enabled or disabled viasystemctl. - Verify: Inspect the
STATEcolumn in the command output.
4. Define which target a unit should start in when enabled.
- Command(s):
grep -i "WantedBy" /usr/lib/systemd/system/<unit>
- Why: The
WantedBy=directive inside the[Install]section of a unit file specifies which target directory receives the unit’s symbolic link when enabled. - Gotchas: Forgetting to run
systemctl daemon-reloadafter modifying custom unit files. - Verify:
systemctl show <unit> -p WantedBy
5. Allow a target to be isolated.
- Command(s):
grep -i "AllowIsolate" /usr/lib/systemd/system/<target>
- Why: The
AllowIsolate=yesdirective in the[Unit]section allows systemd to switch directly to this target while stopping all services not required by it. - Gotchas: Isolating a target stops all non-dependent running services, which will instantly terminate active SSH sessions.
- Verify:
systemctl show <target> -p AllowIsolate
6. Switch the current target to rescue.target.
- Command(s):
systemctl isolate rescue.target
- Why: Stops all non-essential services and drops the system into a single-user maintenance mode with a root shell prompt.
- Gotchas: Requires root password authentication; if the root account is locked or password unknown, access will be blocked.
- Verify:
systemctl is-active rescue.target
7. Map Systemd targets to legacy System V runlevels.
- Command(s):
ls -l /usr/lib/systemd/system/runlevel*.target
- Why: Shows symbolic links mapping traditional SysV runlevels (0–6) to modern systemd targets (e.g.,
runlevel3.target -> multi-user.target). - Gotchas: Assuming traditional SysV runlevel scripts still execute directly; they exist purely as systemd compatibility symlinks.
- Verify: Output displays targets matching runlevels 0 through 6:
runlevel3.target -> multi-user.target
runlevel5.target -> graphical.target
8. Identify the file where GRUB 2 configuration changes should be applied.
- Path / Command:
/etc/default/grub
- Why: Holds primary environment variables (such as
GRUB_CMDLINE_LINUXandGRUB_TIMEOUT) used to generate the final GRUB 2 configuration. - Gotchas: Editing
/boot/grub2/grub.cfgdirectly; manual modifications get overwritten whenever kernel updates executegrub2-mkconfig. - Verify:
cat /etc/default/grub
9. Apply GRUB 2 configuration changes after editing.
- Command(s):
grub2-mkconfig -o /boot/grub2/grub.cfg
- Why: Compiles
/etc/default/gruband scripts in/etc/grub.d/into the operational/boot/grub2/grub.cfgbootloader file. - Gotchas: On RHEL 9 and 10,
/boot/grub2/grub.cfgis unified for both BIOS and UEFI systems; do not use legacy RHEL 8 EFI paths. - Verify:
stat /boot/grub2/grub.cfg
10. Identify the GRUB 2 configuration file generated on a UEFI system.
- Path / Command:
/boot/grub2/grub.cfg
- Why: In RHEL 9/10, boot config paths are unified under
/boot/grub2/grub.cfgfor both UEFI and BIOS systems (using stub loading). - Gotchas: Attempting to update
/boot/efi/EFI/redhat/grub.cfgdirectly on RHEL 9/10, which can break automatic kernel updates. - Verify:
ls -l /boot/grub2/grub.cfg
11. Define what a “unit” is.
- Command(s):
systemctl list-units
- Why: A unit is an abstracted system resource configuration file managed by systemd (e.g.,
.service,.target,.socket,.mount,.timer). - Gotchas: Assuming systemd units only manage services; units also manage storage mounts, network sockets, path monitoring, and timers.
- Verify: Output displays loaded units categorized by types such as
.service,.target, and.socket.
12. Prevent a target from automatically starting on boot.
- Command(s):
systemctl disable <target>
- Why: Removes symbolic links in target dependency folders, preventing the target from being pulled in automatically at system launch.
- Gotchas: Disabling essential targets like
multi-user.targetdirectly can render the system unbootable; modify default targets usingset-defaultinstead. - Verify:
systemctl is-enabled <target>
13. Identify the configuration file for common GRUB 2 changes.
- Path / Command:
/etc/default/grub
- Why: Contains customizable parameters including default boot kernel selections, timeout values, and kernel parameters.
- Gotchas: Modifying scripts directly inside
/etc/grub.d/for basic parameter changes instead of editing/etc/default/grub. - Verify:
ls -l /etc/default/grub
14. Show all service units currently loaded.
- Command(s):
systemctl list-units --type=service
- Why: Filters systemd memory to list only service units currently loaded into memory, showing their active and sub-states.
- Gotchas: Confusing
list-units(loaded in memory) withlist-unit-files(all installed unit files on disk). - Verify: Output lists active service units with
loadedstatus in theLOADcolumn.
15. Create a “want” for a service.
- Command(s):
systemctl enable <service>
- Why: Creates a symbolic link in the corresponding
<target>.wants/directory, establishing a soft startup dependency. - Gotchas:
systemctl enableonly configures boot startup; usesystemctl enable --now <service>to enable and start the service immediately. - Verify:
systemctl is-enabled <service>
16. Switch the current operational target to rescue.target.
- Command(s):
systemctl isolate rescue.target
- Why: Immediately switches system execution state to emergency single-user maintenance mode.
- Gotchas: Remote network interfaces are shut down during isolation, terminating active SSH connections.
- Verify:
systemctl is-active rescue.target
17. Explain why a target cannot be isolated.
- Command(s):
systemctl show <target> -p AllowIsolate
- Why: If a target unit file lacks
AllowIsolate=yesin its[Unit]section, systemd rejects isolation requests to protect system integrity. - Gotchas: Attempting
systemctl isolateon custom targets without explicitly configuringAllowIsolate=yes. - Verify: Output returns:
AllowIsolate=no
18. Find which units depend on a specific service before shutting it down.
- Command(s):
systemctl list-dependencies <service> --reverse
- Why: Displays all systemd units that depend on, require, or want the target service, preventing accidental disruption of dependent services.
- Gotchas: Omitting
--reverse; without this flag, systemctl lists what the service depends on, rather than what depends on it. - Verify: Inspect the resulting dependency tree.
19. Identify the GRUB 2 configuration file for applying changes.
- Path / Command:
/etc/default/grub
- Why: Central point of configuration for modifying kernel flags before building final configuration binaries.
- Gotchas: Editing
/boot/grub2/grub.cfgmanually instead of applying parameters to/etc/default/grub. - Verify: Ensure file exists and parameters are formatted correctly.
20. Run the appropriate command after modifying GRUB 2 configuration.
- Command(s):
grub2-mkconfig -o /boot/grub2/grub.cfg
- Why: Scans
/etc/default/gruband/etc/grub.d/helpers to regenerate/boot/grub2/grub.cfgwith updated directives. - Gotchas: rebooting without executing
grub2-mkconfig, leaving modifications unapplied. - Verify:
stat /boot/grub2/grub.cfg
Lab Tasks
Task 1: Boot Target Practice
- Command(s):
systemctl set-default multi-user.target
reboot
systemctl get-default
-
Why:
-
systemctl set-default: Updates the/etc/systemd/system/default.targetsymlink to targetmulti-user.target. -
reboot: Restarts system to verify non-graphical startup. -
systemctl get-default: Confirms persistent execution target. -
Gotchas: Forgetting to run
get-defaultpost-reboot to confirm target persistence. -
Verify:
systemctl get-default
Task 2: GRUB 2 Practice
- Command(s):
sed -i 's/rhgb quiet//' /etc/default/grub
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
- Why: Removing
rhgb(Red Hat Graphical Boot) andquietfromGRUB_CMDLINE_LINUXenables verbose text output during boot sequence. - Gotchas: Forgetting to run
grub2-mkconfig -o /boot/grub2/grub.cfgto regenerate the bootloader configuration file. - Verify:
cat /proc/cmdline
(Ensure rhgb and quiet are absent from active kernel boot parameters)