[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[rhel6-branch] Only allow one EFI System Partition to exist at a time.



We previously had code to do this that didn't work; it is also removed
in this patch.

Resolves: rhbz#593984
---
 platform.py             |   23 ++++++++++++-----------
 storage/devicetree.py   |    2 +-
 storage/partitioning.py |   11 +++++++++++
 3 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/platform.py b/platform.py
index d18278a..d7a890c 100644
--- a/platform.py
+++ b/platform.py
@@ -205,8 +205,15 @@ class EFI(Platform):
     _maxBootPartSize = 256
 
     def bootDevice(self):
-        mntDict = self._mntDict()
-        return mntDict.get("/boot/efi")
+        bootDev = None
+
+        for part in self.anaconda.id.storage.partitions:
+            if part.format.type == "efi" and self.validBootPartSize(part.size):
+                bootDev = part
+                # if we're only picking one, it might as well be the first
+                break
+
+        return bootDev
 
     def bootloaderChoices(self, bl):
         bootDev = self.bootDevice()
@@ -244,7 +251,7 @@ class EFI(Platform):
             partitions = filter(lambda d: d.type == "partition", req.parents)
 
         # Check that we've got a correct disk label.
-        for p in partitions:        
+        for p in partitions:
             partedDisk = p.disk.format.partedDisk
             labelType = self.diskLabelType(partedDisk.device.type)
             # Allow using gpt with x86, but not msdos with EFI
@@ -256,14 +263,8 @@ class EFI(Platform):
 
     def setDefaultPartitioning(self):
         ret = Platform.setDefaultPartitioning(self)
-
-        # Only add the EFI partition to the default set if there's not already
-        # one on the system.
-        if len(filter(lambda dev: dev.format.type == "efi" and self.validBootPartSize(dev.size),
-                      self.anaconda.id.storage.partitions)) == 0:
-            ret.append(PartSpec(mountpoint="/boot/efi", fstype="efi", size=20,
-                                maxSize=200, grow=True, weight=self.weight(fstype="efi")))
-
+        ret.append(PartSpec(mountpoint="/boot/efi", fstype="efi", size=20,
+                            maxSize=200, grow=True, weight=self.weight(fstype="efi")))
         return ret
 
     def weight(self, fstype=None, mountpoint=None):
diff --git a/storage/devicetree.py b/storage/devicetree.py
index f45e656..250aa43 100644
--- a/storage/devicetree.py
+++ b/storage/devicetree.py
@@ -1831,7 +1831,7 @@ class DeviceTree(object):
                 kwargs["peStart"] = udev_device_get_pv_pe_start(info)
             except KeyError:
                 log.debug("PV %s has no pe_start" % name)
-        elif format_type == "vfat":
+        elif format_type == "vfat" or format_type == "efi":
             # efi magic
             if isinstance(device, PartitionDevice) and device.bootable:
                 efi = formats.getFormat("efi")
diff --git a/storage/partitioning.py b/storage/partitioning.py
index 048539a..6fc4924 100644
--- a/storage/partitioning.py
+++ b/storage/partitioning.py
@@ -105,6 +105,17 @@ def _schedulePartitions(anaconda, disks):
                          "partition request on %s" % bootdev.disk.name)
                 continue
             log.debug("partitioning: allowing a PReP boot partition request")
+        elif request.fstype == "efi":
+            # make sure there never is more than one efi system partition per disk
+            bootdev = anaconda.platform.bootDevice()
+            if (bootdev and
+                anaconda.id.bootloader.drivelist and
+                anaconda.id.bootloader.drivelist[0] == bootdev.disk.name):
+                log.info("partitioning: skipping a EFI System "
+                         "Partition request on %s" % bootdev.disk.name)
+                continue
+            log.debug("partitioning: allowing a EFI System Partition request")
+
 
         # This is a little unfortunate but let the backend dictate the rootfstype
         # so that things like live installs can do the right thing
-- 
1.7.3.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]