DistroBaker 8dd0a3
From 2efdec8ba54caff05548d8711db6a3f9523b157d Mon Sep 17 00:00:00 2001
DistroBaker 8dd0a3
From: Javier Martinez Canillas <javierm@redhat.com>
DistroBaker 8dd0a3
Date: Mon, 8 Mar 2021 17:42:15 +0100
DistroBaker 8dd0a3
Subject: [PATCH] Use the volume UUID to search for the GRUB config in btrfs
DistroBaker 8dd0a3
 partitions
DistroBaker 8dd0a3
DistroBaker 8dd0a3
For UEFI installs, a minimal GRUB config file is created in the EFI System
DistroBaker 8dd0a3
Partition that is used to load the main config file that is located in the
DistroBaker 8dd0a3
/boot/grub2 directory. The partition that contains the latter, is found by
DistroBaker 8dd0a3
the minimal config searching a device with a given filesystem UUID.
DistroBaker 8dd0a3
DistroBaker 8dd0a3
But for this to work the stage2 device must have a filesystem UUID set and
DistroBaker 8dd0a3
blivet doesn't set this for partitions formatted with a btrfs filesystem.
DistroBaker 8dd0a3
DistroBaker 8dd0a3
Because each btrfs volume will have its own UUID, the UUID of the volume
DistroBaker 8dd0a3
that's mounted according to /etc/fstab must be used to search the device.
DistroBaker 8dd0a3
DistroBaker 8dd0a3
Resolves: rhbz#1930567
DistroBaker 8dd0a3
DistroBaker 8dd0a3
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
DistroBaker 8dd0a3
---
DistroBaker 8dd0a3
 pyanaconda/modules/storage/bootloader/efi.py | 8 +++++++-
DistroBaker 8dd0a3
 1 file changed, 7 insertions(+), 1 deletion(-)
DistroBaker 8dd0a3
DistroBaker 8dd0a3
diff --git a/pyanaconda/modules/storage/bootloader/efi.py b/pyanaconda/modules/storage/bootloader/efi.py
DistroBaker 8dd0a3
index 425cb31954..82f60e4c40 100644
DistroBaker 8dd0a3
--- a/pyanaconda/modules/storage/bootloader/efi.py
DistroBaker 8dd0a3
+++ b/pyanaconda/modules/storage/bootloader/efi.py
DistroBaker 8dd0a3
@@ -172,7 +172,13 @@ class EFIGRUB(EFIBase, GRUB2):
DistroBaker 8dd0a3
 
DistroBaker 8dd0a3
         with open(config_path, "w") as fd:
DistroBaker 8dd0a3
             grub_dir = self.config_dir
DistroBaker 8dd0a3
-            fs_uuid = self.stage2_device.format.uuid
DistroBaker 8dd0a3
+            if self.stage2_device.format.type != "btrfs":
DistroBaker 8dd0a3
+                fs_uuid = self.stage2_device.format.uuid
DistroBaker 8dd0a3
+            else:
DistroBaker 8dd0a3
+                fs_uuid = self.stage2_device.format.vol_uuid
DistroBaker 8dd0a3
+
DistroBaker 8dd0a3
+            if fs_uuid is None:
DistroBaker 8dd0a3
+                raise BootLoaderError("Could not get stage2 filesystem UUID")
DistroBaker 8dd0a3
 
DistroBaker 8dd0a3
             grub_dir = util.execWithCapture("grub2-mkrelpath", [grub_dir],
DistroBaker 8dd0a3
                                             root=conf.target.system_root)
DistroBaker 8dd0a3
-- 
DistroBaker 8dd0a3
2.26.2
DistroBaker 8dd0a3