1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

grub2-mkconfigの使い方

Last updated at Posted at 2022-12-17

1. 概要

CentOS7で/etc/default/grubを変更したときの、カーネルへの反映方法を解説します。

2. 解決したい課題

/etc/default/grubを変更したとき、BIOSブートとUEFIブートで、カーネルへの反映方法が異なります。

3. 解決方法

まず、BIOS、UEFIどちらでブートしたのかを確認し、対応する反映方法を実施します。

3.1 BIOS、UEFIどちらでブートしたのかを確認

BIOSブートしたマシンでの実行結果

# [ -d /sys/firmware/efi ] && echo UEFI Booted || echo BIOS Booted
BIOS Booted
#

UEFIブートしたマシンでの実行結果

# [ -d /sys/firmware/efi ] && echo UEFI Booted || echo BIOS Booted
UEFI Booted
#

3.2 BIOSブートされたマシンへのカーネルへの反映方法

# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1160.71.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.71.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-74d201337f7d4c1884bd9f5a09840ab9
Found initrd image: /boot/initramfs-0-rescue-74d201337f7d4c1884bd9f5a09840ab9.img
done
#

3.3 UEFIブートされたマシンへのカーネルへの反映方法

# grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-1160.71.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.71.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-74d201337f7d4c1884bd9f5a09840ab9
Found initrd image: /boot/initramfs-0-rescue-74d201337f7d4c1884bd9f5a09840ab9.img
done
#

4. 類似の解決方法

5. 現在と今後

6. 関連記事

7.リファレンス

8. 付録

/etc/default/grubの記述例です。そのまま使用しないでください。マシンが起動しなくなる可能性があります。

I350のSRIOVの有効化例

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet hugepagesz=2M hugepages=8192 iommu=pt intel_iommu=on pci=assign-busses pci=realloc=on"
GRUB_DISABLE_RECOVERY="true"

X550のSRIOVの有効化例

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet hugepagesz=2M hugepages=8192 intel_iommu=on intel_iommu=on pci=assign-busses pci=realloc=on"
GRUB_DISABLE_RECOVERY="true"

1G HugePageを作る

GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto spectre_v2=retpoline rd.lvm.lv=centos/root rd.lvm.lv=centos/swap rhgb quiet default_hugepagesz=1G hugepagesz=1G hugepages=4 hugepagesz=2M hugepages=1024"
GRUB_DISABLE_RECOVERY="true"
1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?