[rhel6] Fall back to first ESP if none have mountpoints (#1145812)

Brian C. Lane bcl at redhat.com
Mon Nov 3 23:25:45 UTC 2014


The problem with that last patch is it still doesn't fall back to the 1st ESP
if there are none with a mountpoint.  This makes it keep creating new ESPs when
using 'replace linux'.

I'd modify it like this:

---
 platform.py | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/platform.py b/platform.py
index a169e28..a7d32b2 100644
--- a/platform.py
+++ b/platform.py
@@ -248,6 +248,9 @@ class EFI(Platform):
         Return the boot device. The bootloader.drivelist is used to
         set the precedence in cases where multiple partitions are
         available from multiple devices.
+
+        Return the first ESP with a mountpoint, if there is one.
+        Otherwise return the first ESP.
         """
         drive = self.anaconda.id.bootloader.drivelist[0]
 
@@ -257,12 +260,17 @@ class EFI(Platform):
                part.format.type == "efi" and \
                self.validBootPartSize(part.size)
 
-        if self.isEfi:
-            isBootDevice = lambda part: _isBoot(part) and part.format.mountpoint
-        else:
-            isBootDevice = _isBoot
+        bootDevice = None
+        for part in self.anaconda.id.storage.partitions:
+            if not _isBoot(part):
+                continue
+            if part.format.mountpoint:
+                bootDevice = part
+                break
+            elif bootDevice is None:
+                bootDevice = part
 
-        return next((p for p in self.anaconda.id.storage.partitions if isBootDevice(p)), None)
+        return bootDevice
 
     def bootloaderChoices(self, bl):
         bootDev = self.bootDevice()
-- 
1.9.3



More information about the anaconda-patches mailing list