parted always renumbers partitions when a partition gets removed, so if we have p5 and p6, and then p5 gets removed then p6 becomes p5, if we then check for p6 using getPartitionByPath() it will show up as non existing even though it does exist, but it has been renamed to p5. This patch fixes this by simply setting the PartitionDevice's pedPartition to None when it was removed from its disk, as the PartitionDevice is of no use to use after that anyways (and we already check that we do not try to remove None from the disk). --- storage/devices.py | 7 +------ storage/partitioning.py | 4 ++-- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/storage/devices.py b/storage/devices.py index 209ea4f..6aa462c 100644 --- a/storage/devices.py +++ b/storage/devices.py @@ -1011,10 +1011,6 @@ class PartitionDevice(StorageDevice): return self.partType & parted.PARTITION_PROTECTED def _getPartedPartition(self): - if self.disk and not self._partedPartition: - pdisk = self.disk.partedDisk - self._partedPartition = pdisk.getPartitionByPath(self.path) - return self._partedPartition def _setPartedPartition(self, partition): @@ -1158,8 +1154,7 @@ class PartitionDevice(StorageDevice): self.disk.addPartition(self) self.disk.commit() - # this will force a lookup on next access, which we want - self.partedPartition = None + self.partedPartition = self.disk.partedDisk.getPartitionByPath(self.path) self.exists = True self.setup() diff --git a/storage/partitioning.py b/storage/partitioning.py index d824fa6..0f741ec 100644 --- a/storage/partitioning.py +++ b/storage/partitioning.py @@ -614,10 +614,10 @@ def allocatePartitions(disks, partitions): #_part.disk.partedDisk.removePartition(_part.partedPartition) partedDisk = partedDisks[_part.disk.partedDisk.device.path] #log.debug("removing part %s (%s) from disk %s (%s)" % (_part.partedPartition.path, [p.path for p in _part.partedPartition.disk.partitions], partedDisk.device.path, [p.path for p in partedDisk.partitions])) - if not partedDisk.getPartitionByPath(_part.path): - continue partedDisk.removePartition(_part.partedPartition) + _part.partedPartition = None + # remove empty extended so it doesn't interfere extended = partedDisk.getExtendedPartition() if extended and not partedDisk.getLogicalPartitions(): -- 1.6.2 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list