الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

grub2-mkconfig

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

المستوى
امتحان RHCSA
المجموعة
النواة والعتاد
يحتاج root
نعم
الحزمة
grub2-tools

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

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.

طريقة الكتابة

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

الأجزاء الرئيسية

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).

الخيارات 4

الأكثر استخدامًا

-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.

أمثلة 10

$ مستخدم عادي# بصلاحية root (أو مع 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.

الملفات

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

رموز الخروج

0Done.
1Error.