q21-grub-bootloader
Énoncé§
Solve this question on: terminal
- Set the default GRUB timeout to
3seconds. - Add the kernel boot parameter
quietto all entries. - Regenerate the GRUB configuration file so the changes apply at next boot.
- Write the current default kernel command line into
/opt/course/21/cmdline.
Solution§
Step 1 — Edit GRUB defaults§
The main file to edit is /etc/default/grub:
sudo vim /etc/default/grub
Set or update:
GRUB_TIMEOUT=3
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
Key variables to remember:
GRUB_DEFAULT— index or title of the default entry (0,saved, …)GRUB_TIMEOUT— countdown in seconds before booting the default entryGRUB_CMDLINE_LINUX— applied to all entries (rescue included)GRUB_CMDLINE_LINUX_DEFAULT— applied to normal (non-rescue) entries only
Step 2 — Regenerate the GRUB config§
Debian/Ubuntu:
sudo update-grub
# equivalent to:
sudo grub-mkconfig -o /boot/grub/grub.cfg
RHEL/Fedora (BIOS):
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
RHEL/Fedora (UEFI):
sudo grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg
Step 3 — Inspect the active kernel cmdline§
cat /proc/cmdline > /opt/course/21/cmdline
Reinstall GRUB on the MBR§
If the bootloader itself is damaged:
sudo grub-install /dev/sda # BIOS systems
sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
Boot temporarily into another mode§
At the GRUB menu, press e on the entry and append to the linux line:
singleor1— single-user (rescue) modesystemd.unit=rescue.targetsystemd.unit=emergency.targetinit=/bin/bash— bypass init entirely
Press Ctrl+X or F10 to boot the modified entry once.
—The Gardener