skip btrfs subvolumes when detecting ESP partitions

Resolves: RHEL-26827
This commit is contained in:
Lukáš Zaoral 2024-04-04 09:52:01 +02:00 committed by Pavel Cahyna
parent 66f9381dbd
commit 395852aadb
2 changed files with 67 additions and 0 deletions

View File

@ -0,0 +1,62 @@
From c8409e1f2972e9cd87d9390ca0b52b908d1a872a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= <lzaoral@redhat.com>
Date: Wed, 20 Mar 2024 12:22:46 +0100
Subject: [PATCH] skip btrfs subvolumes when detecting ESP partitions
The idea is to find all direct partitions that contain the ESP
mount point and to skip all other transitive `fs:` dependencies.
The `diskdeps.conf` file contains following entries on default Fedora
installations (the list was shortened to only the relevant ones):
```
/dev/vda1 /dev/vda
/dev/vda4 /dev/vda
/dev/vda5 /dev/vda
fs:/boot/efi /dev/vda1
fs:/boot/efi fs:/boot
fs:/boot/efi fs:/
fs:/boot/efi btrfsmountedsubvol:/
fs:/boot /dev/vda4
fs:/boot fs:/
fs:/boot btrfsmountedsubvol:/
fs:/ /dev/vda5
btrfsmountedsubvol:/ /dev/vda5
```
The ESP partition is only on `/dev/vda1`. However, the `find_partition` call
was not taking into account the need to skip mounted btrfs subvolumes as well.
Therefore, `/dev/vda5` was listed as an ESP partition as well.
This change makes sure that only direct ESP partitions are listed and
fixes a bug where ReaR would create broken BootXXXX entries which point to
completely unrelated partitions.
Relevant excerpts from logs:
```
++ efibootmgr --create --gpt --disk /dev/vda --part 1 --write-signature --label 'RedHatEnterpriseServer 41' --loader '\EFI\fedora\grubx64.efi'
...
++ efibootmgr --create --gpt --disk /dev/vda --part 5 --write-signature --label 'RedHatEnterpriseServer 41' --loader '\EFI\fedora\grubx64.efi'
```
---
usr/share/rear/finalize/Linux-i386/670_run_efibootmgr.sh | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/usr/share/rear/finalize/Linux-i386/670_run_efibootmgr.sh b/usr/share/rear/finalize/Linux-i386/670_run_efibootmgr.sh
index 33d87767..8b658618 100644
--- a/usr/share/rear/finalize/Linux-i386/670_run_efibootmgr.sh
+++ b/usr/share/rear/finalize/Linux-i386/670_run_efibootmgr.sh
@@ -47,7 +47,10 @@ fi
# accounting for possible trailing slashes in TARGET_FS_ROOT
esp_mountpoint_inside="${esp_mountpoint#${TARGET_FS_ROOT%%*(/)}}"
-boot_efi_parts=$( find_partition "fs:$esp_mountpoint_inside" fs )
+# Find all partitions with the ESP mount point and skip all other transitive
+# 'fs' and 'btrfsmountedsubvol' components in LAYOUT_DEPS (var/lib/rear/layout/diskdeps.conf)
+# to support ESP on software RAID (cf. https://github.com/rear/rear/pull/2608).
+boot_efi_parts=$( find_partition "fs:$esp_mountpoint_inside" 'btrfsmountedsubvol fs' )
if ! test "$boot_efi_parts" ; then
LogPrint "Unable to find ESP $esp_mountpoint_inside in layout"
LogPrint "Trying to determine device currently mounted at $esp_mountpoint as fallback"
--
2.44.0

View File

@ -85,6 +85,10 @@ Patch115: rear-skip-invalid-drives-RHEL-22863.patch
# https://github.com/rear/rear/commit/283efdaea10ff62dc94e968f74e1136b8384a954
Patch116: rear-uefi-booting-with-multiple-cdrom-devices.patch
# skip btrfs subvolumes when detecting ESP partitions
# https://github.com/rear/rear/commit/c8409e1f2972e9cd87d9390ca0b52b908d1a872a
Patch117: rear-skip-btrfs-subvolumes-when-detecting-ESP-partitions.patch
######################
# downstream patches #
######################
@ -232,6 +236,7 @@ EOF
#-- CHANGELOG -----------------------------------------------------------------#
%changelog
* Mon Aug 05 2024 Lukáš Zaoral <lzaoral@redhat.com> - 2.7-10
- skip btrfs subvolumes when detecting ESP partitions
- fix booting on UEFI systems with multiple CDROM devices
- fix copying of console kernel cmdline parameters