[rhel6] Only set GPT boot flag on ESP partition (#1139606)

Brian C. Lane bcl at redhat.com
Wed Sep 10 23:25:14 UTC 2014


Flags on GPT partitions are GUIDs, so only one can be set. The boot flag
should only be set for the EFI System Partition, for everything else
let the flags be set by the partition type (eg. prepboot).
---
 storage/__init__.py | 48 ++++++++++++++++++++++++++++++------------------
 1 file changed, 30 insertions(+), 18 deletions(-)

diff --git a/storage/__init__.py b/storage/__init__.py
index 8e227c5..2984337 100644
--- a/storage/__init__.py
+++ b/storage/__init__.py
@@ -367,24 +367,36 @@ class Storage(object):
             bootDevs = []
         else:
             for dev in bootDevs:
-                if hasattr(dev, "bootable"):
-                    # Dos labels can only have one partition marked as active
-                    # and unmarking ie the windows partition is not a good idea
-                    skip = False
-                    if dev.disk.format.partedDisk.type == "msdos":
-                        for p in dev.disk.format.partedDisk.partitions:
-                            if p.type == parted.PARTITION_NORMAL and \
-                               p.getFlag(parted.PARTITION_BOOT):
-                                skip = True
-                                break
-                    if skip:
-                         log.info("not setting boot flag on %s as there is"
-                                  "another active partition" % dev.name)
-                         continue
-                    log.info("setting boot flag on %s" % dev.name)
-                    dev.bootable = True
-                    dev.disk.setup()
-                    dev.disk.format.commitToDisk()
+                if not hasattr(dev, "bootable"):
+                    log.info("Skipping %s, not bootable", dev)
+                    continue
+
+                # Dos labels can only have one partition marked as active
+                # and unmarking ie the windows partition is not a good idea
+                skip = False
+                if dev.disk.format.partedDisk.type == "msdos":
+                    for p in dev.disk.format.partedDisk.partitions:
+                        if p.type == parted.PARTITION_NORMAL and \
+                           p.getFlag(parted.PARTITION_BOOT):
+                            skip = True
+                            break
+
+                # GPT labeled disks should only have bootable set on the
+                # EFI system partition (parted sets the EFI System GUID on
+                # GPT partitions with the boot flag, overwriting any other
+                # GUID that has already been set)
+                if dev.disk.format.type == "gpt" and \
+                   dev.format.type != "efi":
+                    skip = True
+
+                if skip:
+                    log.info("Skipping setting bootable on %s", dev.name)
+                    continue
+
+                log.info("setting boot flag on %s" % dev.name)
+                dev.bootable = True
+                dev.disk.setup()
+                dev.disk.format.commitToDisk()
 
         self.dumpState("final")
 
-- 
1.9.3



More information about the anaconda-patches mailing list