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

grub2-mkconfig

Generate the GRUB 2 configuration file from /etc/default/grub and the scripts in /etc/grub.d/.

Niveau
RHCSA-examen
Groep
Kernel en hardware
Root nodig
Ja
Pakket
grub2-tools

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

Wat het doet

Never edit grub.cfg by hand. Change /etc/default/grub, then run grub2-mkconfig -o /boot/grub2/grub.cfg (the same path on BIOS and UEFI on current RHEL). On RHEL with BLS, kernel arguments live in the entry files; add --update-bls-cmdline when you changed GRUB_CMDLINE_LINUX so the entries get the new arguments.

Zo schrijf je het

grub2-mkconfig [-o FILE] [--update-bls-cmdline]

Belangrijkste delen

GRUB_TIMEOUT
Seconds the menu waits.
GRUB_DEFAULT
Default entry (saved = use grubenv).
GRUB_CMDLINE_LINUX
Kernel arguments for all kernels.
GRUB_TERMINAL_OUTPUT
console, serial, gfxterm.
GRUB_DISABLE_RECOVERY
No rescue entries.
GRUB_ENABLE_BLSCFG
Use BLS entries (true on RHEL).

Opties 4

Meest gebruikt

-o, --output=FILE
Write to this file (without: print to the screen).
--update-bls-cmdline
Also write GRUB_CMDLINE_LINUX into the BLS entries.
-h, --help
Show help.
-V, --version
Show the version.

Voorbeelden 10

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

  1. 1Regenerate after a change

    grub2-mkconfig -o /boot/grub2/grub.cfg
    Generating grub configuration file ...
    done

    After every edit of /etc/default/grub.

  2. 2Change the timeout

    sed -i 's/^GRUB_TIMEOUT=.*/GRUB_TIMEOUT=10/' /etc/default/grub
    grub2-mkconfig -o /boot/grub2/grub.cfg

    Menu waits 10 seconds.

  3. 3Change kernel arguments for all kernels

    vim /etc/default/grub
    grub2-mkconfig -o /boot/grub2/grub.cfg --update-bls-cmdline

    Without the option the existing entries keep their old arguments.

  4. 4Preview without writing

    grub2-mkconfig | less

    Check before you overwrite.

  5. 5Back up the old config

    cp -a /boot/grub2/grub.cfg /root/grub.cfg.bak

    Easy way back.

  6. 6Show the menu on a serial console

    grep -E 'GRUB_TERMINAL|GRUB_SERIAL' /etc/default/grub

    For VMs without a screen.

  7. 7Password for the GRUB menu (security)

    grub2-setpassword

    Nobody can edit boot entries at the console without it (stops rd.break tricks).

  8. 8Where is the config on UEFI?

    cat /boot/efi/EFI/redhat/grub.cfg

    A small stub that loads /boot/grub2/grub.cfg.

  9. 9Boot an entry once

    grub2-reboot 1; reboot

    Only the next boot uses entry 1.

  10. 10Check the BLS entries afterwards

    grep options /boot/loader/entries/*.conf

    The kernel arguments per entry.

Bestanden

/etc/default/grub
Your settings.
/etc/grub.d/
Scripts that build the config.
/boot/grub2/grub.cfg
Generated config.
/boot/loader/entries/
BLS entries.

Exitcodes

0 :: Done. 1 :: Error.