[PATCH 07/13] Move zerombr handling so doesn't depend on the clearpart setting.

David Lehman dlehman at redhat.com
Fri Jun 29 14:14:00 UTC 2012


---
 pyanaconda/storage/__init__.py     |   17 ++++++++++++++++-
 pyanaconda/storage/partitioning.py |   22 ----------------------
 2 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index be795b3..e05732f 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -509,7 +509,6 @@ class Storage(object):
         if self.bootloader:
             # clear out bootloader attributes that refer to devices that are
             # no longer in the tree
-            self.updateBootLoaderDiskList()
             self.bootloader.stage1_disk = None
             self.bootloader.stage1_device = None
             self.bootloader.stage2_device = None
@@ -518,6 +517,22 @@ class Storage(object):
 
         self.dumpState("initial")
 
+        # if zerombr is set, go ahead and slap a disklabel on any disk that
+        # doesn't have (recognizeable) formatting
+        if self.config.zeroMbr:
+            for disk in self.disks:
+                if disk.format.type is None:
+                    log.info("zerombr: initializing %s" % disk.name)
+
+                    labelType = storage.platform.bestDiskLabelType(disk)
+                    newLabel = getFormat("disklabel", device=disk.path,
+                                         labelType=labelType)
+                    create_action = ActionCreateFormat(disk, format=newLabel)
+                    storage.devicetree.registerAction(create_action)
+
+        # we may have added candidate boot disks just above by initializing
+        self.updateBootLoaderDiskList()
+
     @property
     def unusedDevices(self):
         used_devices = []
diff --git a/pyanaconda/storage/partitioning.py b/pyanaconda/storage/partitioning.py
index d764134..1cb9b94 100644
--- a/pyanaconda/storage/partitioning.py
+++ b/pyanaconda/storage/partitioning.py
@@ -455,28 +455,6 @@ def clearPartitions(storage):
         recursiveRemove(storage, part)
         log.debug("partitions: %s" % [p.getDeviceNodeName() for p in part.partedPartition.disk.partitions])
 
-    # now clear devices that are not partitions and were not implicitly cleared
-    # when clearing partitions
-    not_visited = [d for d in storage.devices if not d.partitioned]
-    while not_visited:
-        for device in [d for d in not_visited if d.isleaf]:
-            not_visited.remove(device)
-
-            if not shouldClear(device, storage.config.clearPartType, storage.config.clearPartDisks, storage.config.clearPartDevices):
-                continue
-
-            recursiveRemove(storage, device)
-
-            # put disklabels on unpartitioned disks
-            if device.isDisk and not d.partitioned:
-                labelType = storage.platform.bestDiskLabelType(disk)
-                newLabel = getFormat("disklabel", device=disk.path,
-                                     labelType=labelType)
-                create_action = ActionCreateFormat(disk, format=newLabel)
-                storage.devicetree.registerAction(create_action)
-
-        not_visited = [d for d in storage.devices if d in not_visited]
-
     # now remove any empty extended partitions
     removeEmptyExtendedPartitions(storage)
 
-- 
1.7.7.6



More information about the anaconda-patches mailing list