diff options
author | David Lehman <dlehman@redhat.com> | 2010-04-14 20:56:29 -0500 |
---|---|---|
committer | David Lehman <dlehman@redhat.com> | 2010-04-15 10:44:22 -0500 |
commit | 2de535b2343ec6d4c24fdf5958b9f5d0e2f42937 (patch) | |
tree | be6c499749475e507b4df3a6936c7a6faff91b18 /storage/partitioning.py | |
parent | 46743ff2b021b3d9b3a2645fe6f2153f3891a9d2 (diff) | |
download | anaconda-2de535b2343ec6d4c24fdf5958b9f5d0e2f42937.tar.gz anaconda-2de535b2343ec6d4c24fdf5958b9f5d0e2f42937.tar.xz anaconda-2de535b2343ec6d4c24fdf5958b9f5d0e2f42937.zip |
Ensure proper disklabel type on boot disk if CLEARPART_TYPE_ALL. (#570483, #530225)
If the user specified "clearpart --all" or chose "Use All Space",
make sure that the boot disk gets initialized with a disklabel
whose type is appropriate for the platform's bootloader.
Diffstat (limited to 'storage/partitioning.py')
-rw-r--r-- | storage/partitioning.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/storage/partitioning.py b/storage/partitioning.py index 7cc478e29..80fbbbd58 100644 --- a/storage/partitioning.py +++ b/storage/partitioning.py @@ -373,6 +373,45 @@ def clearPartitions(storage): # now remove any empty extended partitions removeEmptyExtendedPartitions(storage) + _platform = storage.anaconda.platform + + # make sure that the the boot device has the correct disklabel type if + # we're going to completely clear it. + for disk in storage.partitioned: + if not storage.anaconda.bootloader.drivelist: + break + + if disk.name != storage.anaconda.bootloader.drivelist[0]: + continue + + if storage.clearPartType != CLEARPART_TYPE_ALL or \ + (storage.clearPartDisks and disk.name not in storage.clearPartDisks): + continue + + # don't reinitialize the disklabel if the disk contains install media + if filter(lambda p: p.dependsOn(disk), storage.protectedDevices): + continue + + nativeLabelType = _platform.diskLabelType(disk.partedDevice.type) + if disk.format.labelType == nativeLabelType: + continue + + if disk.format.labelType == "mac": + # remove the magic apple partition + for part in storage.partitions: + if part.disk == disk and part.partedPartition.number == 1: + log.debug("clearing %s" % part.name) + # We can't schedule the apple map partition for removal + # because parted will not allow us to remove it from the + # disk. Still, we need it out of the devicetree. + storage.devicetree._removeDevice(part, moddisk=False) + + destroy_action = ActionDestroyFormat(disk) + newLabel = getFormat("disklabel", device=disk.path) + create_action = ActionCreateFormat(disk, format=newLabel) + storage.devicetree.registerAction(destroy_action) + storage.devicetree.registerAction(create_action) + def removeEmptyExtendedPartitions(storage): for disk in storage.partitioned: log.debug("checking whether disk %s has an empty extended" % disk.name) |