
나는 CentOS 7에서 AlmaLinux 8로 시스템 업그레이드를 꽤 성공적으로 수행했습니다.여기). 프로세스 중에 이상한 일이 발생했고 GRUB는 부팅 항목을 완전히 잃어버렸고 이를 재구축하려는 나의 제한된 노력/그것(실제로는 AlmaLinux 8 커널 항목만 필요하고 업데이트까지 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.
그런 다음 Lish & 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