
CentOS 7からAlmaLinux 8へのシステムアップグレードをかなりうまく実行しました(前述のとおり)ここ)。その過程で奇妙なことが起こり、GRUB のブート エントリが完全に失われ、それらを再構築するための私の限られた努力 (実際に必要なのは AlmaLinux 8 カーネル エントリのみで、これまでのところ更新から 1 つのvmlinuz
+initrd
イメージしかありません) は失敗に終わりました (特に、数十年前の Gentoo 時代以来、GRUB を直接いじる必要がなかったため)。
現在、サーバーを起動するには、基本的に Linode サーバー上の LISH (具体的には Glish) コンソールに移動する必要があり、再起動すると次の画面が表示されます。
グリッシュ:
SeaBIOS (version rel-1.12.1-0.ga5ca58e9aef-prebuilt.qemu.org)
iPXE (http://ipxe.org) 00:04.0 C980 PCI2.10 PnP PMM+7FF90F20+7FEF0F20 C980
Booting from ROM...
Welcome to GRUB!
error: variable `prefix' isn't set.
次に、英語とWeblishで:
GNU GRUB version 2.04
Minimal BASH-like line editing is supported. For the first word, TAB
lists possible command completions. Anywhere else TAB lists possible
device or file completions.
grub> _
次に、システムを非シングル ユーザー モードで起動させるために必死の努力で自分でまとめた次のような内容を入力してls (hd0)/boot/
、起動させる必要があります。
set root=(hd0)
linux /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64 root=/dev/sda console=ttyS0,19200n8
initrd /boot/initramfs-4.18.0-372.9.1.el8.x86_64.img
boot
( 調査と議論の末、発行されるべきブート引数のおそらく洗練されたセットが見つかりました。
set root=(hd0)
linux /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64 root=/dev/sda ro crashkernel=auto rhgb console=ttyS0,19200n8 net.ifnames=0
initrd /boot/initramfs-4.18.0-372.9.1.el8.x86_64.img
boot
)
次のコマンドを使用して、これを単純に修復できると考えましたgrub2-mkconfig
が、ご覧のとおり、エントリが見つかりませんでした。
$ grub2-mkconfig --output /boot/grub2/grub.cfg
Generating grub configuration file ...
done
生成されたセクションを見ると、次のことb2/grub.cfg :: 10_linux
がわかります。
### BEGIN /etc/grub.d/10_linux ###
insmod ext2
set root='hd1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0 --hint-efi=hd0 --hint-baremetal=ahci0 --hint='hd1' 06e9a827-47b4-43f9-8e01-91b3852f86a8
else
search --no-floppy --fs-uuid --set=root 06e9a827-47b4-43f9-8e01-91b3852f86a8
fi
insmod ext2
set boot='hd1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=boot --hint-bios=hd0 --hint-efi=hd0 --hint-baremetal=ahci0 --hint='hd1' 06e9a827-47b4-43f9-8e01-91b3852f86a8
else
search --no-floppy --fs-uuid --set=boot 06e9a827-47b4-43f9-8e01-91b3852f86a8
fi
# This section was generated by a script. Do not modify the generated file - all changes
# will be lost the next time file is regenerated. Instead edit the BootLoaderSpec files.
#
# The blscfg command parses the BootLoaderSpec files stored in /boot/loader/entries and
# populates the boot menu. Please refer to the Boot Loader Specification documentation
# for the files format: https://www.freedesktop.org/wiki/Specifications/BootLoaderSpec/.
# The kernelopts variable should be defined in the grubenv file. But to ensure that menu
# entries populated from BootLoaderSpec files that use this variable work correctly even
# without a grubenv file, define a fallback kernelopts variable if this has not been set.
#
# The kernelopts variable in the grubenv file can be modified using the grubby tool or by
# executing the grub2-mkconfig tool. For the latter, the values of the GRUB_CMDLINE_LINUX
# and GRUB_CMDLINE_LINUX_DEFAULT options from /etc/default/grub file are used to set both
# the kernelopts variable in the grubenv file and the fallback kernelopts variable.
if [ -z "${kernelopts}" ]; then
set kernelopts="root=/dev/sda ro crashkernel=auto rhgb console=ttyS0,19200n8 net.ifnames=0 "
fi
insmod blscfg
blscfg
### END /etc/grub.d/10_linux ###
また、/boot/loader/entries/
BLS 経由で起動する必要があるものに対応すると思われるファイルも確かにあります。
title AlmaLinux (4.18.0-372.9.1.el8.x86_64) 8.6 (Sky Tiger)
version 4.18.0-372.9.1.el8.x86_64
linux /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64
initrd /boot/initramfs-4.18.0-372.9.1.el8.x86_64.img $tuned_initrd
options $kernelopts $tuned_params
id almalinux-20220510130458-4.18.0-372.9.1.el8.x86_64
grub_users $grub_users
grub_arg --unrestricted
grub_class kernel
そしてgrubenv
、
$ grub2-editenv list
saved_entry=4f09fa5fdd3642fa85221d7c11370603-4.18.0-372.9.1.el8.x86_64
kernelopts=root=/dev/sda ro crashkernel=auto rhgb console=ttyS0,19200n8 net.ifnames=0
boot_indeterminate=1
起動時の GRUB エントリには次の内容が含まれている必要があるようです:
linux /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64 root=/dev/sda ro crashkernel=auto rhgb console=ttyS0,19200n8 net.ifnames=0
しかし、そうではありません...そして、この時点では実際に手動で何も変更していないので、GRUB がどこでどのように混乱しているのかわかりません。
健全性チェックとして、パッケージが期待どおりにインストールされていることを確認しました。
$ dnf install kernel grub2
Last metadata expiration check: 2:31:00 ago on Fri Jun 17 13:43:41 2022.
Package kernel-4.18.0-372.9.1.el8.x86_64 is already installed.
Package grub2-pc-1:2.02-123.el8.alma.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
結局のところ、GRUB は見つからないか、解析に失敗するようですgrub.cfg
...
/boot/grub2/grub.cfg
更新が で行われているようで、新しい EMPTY フォルダーが で生成されていることに気づいたので、EFI に関連する何らかの変更があったのではないかと考え、そこでも/boot/efi/EFI/almalinux/
を生成してみました。grub.cfg
$ grub2-mkconfig --output /boot/efi/EFI/almalinux/grub.cfg
Generating grub configuration file ...
done
しかし、ご覧のとおり、生成中および生成中にはまだエントリがなく、再起動しても BLS の自動生成/使用も実行されませんでした (発生する可能性があると理解していると思います)。
/boot/
関連する可能性のあるさまざまなフォルダー の内容は次のとおりです。https://gist.github.com/ylluminate/d469ce8ace202a57f67f5aed255154cd
GRUB を再び構築および/または解析して適切な構成を使用するにはどうすればよいでしょうか?
答え1
Linode サーバーのコンテキストでこの問題を解決する鍵は、を無効にしGRUB_ENABLE_BLSCFG
て再実行することであることがわかりましたgrub2-mkconfig
。例:
$ nano /etc/default/grub
### set: GRUB_ENABLE_BLSCFG=false
$ grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.18.0-372.9.1.el8.x86_64
Found initrd image: /boot/initramfs-4.18.0-372.9.1.el8.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-4f09fa5fdd3642fa85221d7c11370603
Found initrd image: /boot/initramfs-0-rescue-4f09fa5fdd3642fa85221d7c11370603.img
done