81 lines
3.0 KiB
Diff
81 lines
3.0 KiB
Diff
From 11e868ea6e7888a8dcc547376ab0179a930834f6 Mon Sep 17 00:00:00 2001
|
|
From: Petr Stodulka <pstodulk@redhat.com>
|
|
Date: Mon, 8 Mar 2021 23:58:45 +0100
|
|
Subject: [PATCH 2/2] UEFI fix [2/2]: Fix the broken bootloader when upgrade
|
|
without --cleanup-post
|
|
|
|
Fixes the post-upgrade script to ensure the EFI binary file is always
|
|
recovered during the upgrade so the UEFI bootloader is not broken:
|
|
- ensure the legacy grub package is always removed
|
|
- install grub2, grub2-efi, and efibootmgr packages that are expected
|
|
to be installed in case of EFI boot
|
|
- always recover the EFI binary file
|
|
|
|
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1915393
|
|
---
|
|
RHEL6_7/system/uefi/efibootorder_fix_post.sh | 35 ++++++++++++++++----
|
|
1 file changed, 28 insertions(+), 7 deletions(-)
|
|
|
|
diff --git a/RHEL6_7/system/uefi/efibootorder_fix_post.sh b/RHEL6_7/system/uefi/efibootorder_fix_post.sh
|
|
index 27b29b5..134b1b5 100755
|
|
--- a/RHEL6_7/system/uefi/efibootorder_fix_post.sh
|
|
+++ b/RHEL6_7/system/uefi/efibootorder_fix_post.sh
|
|
@@ -8,26 +8,47 @@ log_error() {
|
|
echo >&2 "Error: $@"
|
|
}
|
|
|
|
-log_info "Check the EFI:"
|
|
-efibootmgr || {
|
|
- log_error "Something is wrong. Cannot use the efibootmgr utility"
|
|
- exit 1
|
|
+
|
|
+################################
|
|
+# Handling set of install grub related RPMs
|
|
+# - legacy grub is expected to be removed (before or during this script)
|
|
+# - the grub2 package is expected to be installed
|
|
+# - efiboot package is expected to be installed
|
|
+################################
|
|
+rpm -q grub >/dev/null && {
|
|
+ # the legacy grub is still installed. Remove it first and install the grub2
|
|
+ # we have to recover the EFI boot binary after the grub is uninstalled
|
|
+ log_info "The legacy grub is still installed. Uninstalling.."
|
|
+ yum -y remove grub
|
|
+}
|
|
+
|
|
+rpm -q grub2 grub2-efi efibootmgr >/dev/null || {
|
|
+ log_info "Installing grub2, grub2-efi, and efibootmgr packages"
|
|
+ yum -y install grub2 grub2-efi efibootmgr
|
|
}
|
|
|
|
-# the $efibin_path is removed during the upgrade as it is provided by the grub
|
|
-# rpm which is removed during the upgrade
|
|
+# the $efibin_path is removed (as it is provided by the grub rpm which is
|
|
+# supposed to be always removed).
|
|
efibin_path="/boot/efi/EFI/redhat/grub.efi"
|
|
eficonf_path="/boot/efi/EFI/redhat/grub.conf"
|
|
|
|
-# restore the files from the backup
|
|
+# restore the EFI file from the backup (we want to reach this step always)
|
|
log_info "Restoring EFI files."
|
|
cp -a ${efibin_path}{.preupg,}
|
|
+
|
|
# we do not want to apply the backup of the configuration file,
|
|
# as the backup will not contain probably working configuration; however,
|
|
# in case the configuration file is already missing, it could be in some
|
|
# rare cases better than nothing
|
|
[ -e "$eficonf_path" ] || cp -a ${eficonf_path}{.preupg,}
|
|
|
|
+log_info "Check the EFI:"
|
|
+efibootmgr || {
|
|
+ log_error "Something is wrong. Cannot use the efibootmgr utility"
|
|
+ exit 1
|
|
+}
|
|
+
|
|
+
|
|
|
|
# e.g.: BootCurrent: 0001
|
|
current_boot=$(efibootmgr | grep "^BootCurrent:" | cut -d ":" -f 2- | sed -r "s/^\s*(.*)\s*$/\1/" | grep -o "^[0-9A-F]*")
|
|
--
|
|
2.30.2
|
|
|