Garden of KnowledgeApplied Sciences › Computer Science › Software › Security › Certifications › LFCS

q21-grub-bootloader

Énoncé§

Solve this question on: terminal

  1. Set the default GRUB timeout to 3 seconds.
  2. Add the kernel boot parameter quiet to all entries.
  3. Regenerate the GRUB configuration file so the changes apply at next boot.
  4. 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:

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:

Press Ctrl+X or F10 to boot the modified entry once.

—The Gardener