Skip to content

Commit 3f2aa8f

Browse files
committed
fix(reinstall_secure_boot_packages): remove /root from the kernel path if EL10 with BTRFS, and /boot isn't BTRFS subvolume.
1 parent d93bf63 commit 3f2aa8f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

almalinux-deploy.sh

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,6 +1225,7 @@ add_efi_boot_record() {
12251225

12261226

12271227
reinstall_secure_boot_packages() {
1228+
local -r os_version="${1%%.*}"
12281229
if get_status_of_stage "reinstall_secure_boot_packages"; then
12291230
return 0
12301231
fi
@@ -1235,7 +1236,18 @@ reinstall_secure_boot_packages() {
12351236
yum reinstall "${pkg}" -y
12361237
fi
12371238
done
1238-
kernel_package="$(rpm -qf "$(grubby --default-kernel)")"
1239+
kernel_path="$(grubby --default-kernel)"
1240+
# If migrating to AlmaLinux 10+ with BTRFS, handle subvolume paths
1241+
if [[ "${os_version}" -ge "10" ]] && [[ "$(findmnt -n -o FSTYPE /)" == "btrfs" ]]; then
1242+
# Cache btrfs subvolume list to avoid multiple expensive calls
1243+
local btrfs_subvols
1244+
btrfs_subvols="$(btrfs subvolume list /)"
1245+
# If no /boot subvolume exists but /root subvolume does, adjust kernel path
1246+
if ! grep -q 'boot' <<< "$btrfs_subvols" && grep -q 'root' <<< "$btrfs_subvols"; then
1247+
kernel_path="${kernel_path/\/root/}"
1248+
fi
1249+
fi
1250+
kernel_package="$(rpm -qf "$kernel_path")"
12391251
if [[ "AlmaLinux" != "$(rpm -q --queryformat '%{vendor}' "${kernel_package}")" ]]; then
12401252
yum reinstall "${kernel_package}" -y
12411253
fi
@@ -1392,7 +1404,7 @@ main() {
13921404
if [ $is_container -eq 0 ]; then
13931405
install_kernel
13941406
grub_update
1395-
reinstall_secure_boot_packages
1407+
reinstall_secure_boot_packages "${os_version}"
13961408
add_efi_boot_record
13971409
fi
13981410
check_custom_kernel

0 commit comments

Comments
 (0)