Hi,
On 01/12/2010 10:29 PM, David Lehman wrote:
On Tue, 2010-01-12 at 21:54 +0100, Hans de Goede wrote:
Hi,
On 01/12/2010 09:06 PM, David Lehman wrote:
This becomes important when removing a disklabel from a device
which has a disklabel and partitions but which is not something
we support partitioning (eg: lvm lv). In normal cases the
partitions will already have been removed, but in the case of
an unsupported partitioned device we ignore the partitions when
scanning and so have to remove them this way.
---
storage/formats/disklabel.py | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/storage/formats/disklabel.py b/storage/formats/disklabel.py
index e5fab94..567d26b 100644
--- a/storage/formats/disklabel.py
+++ b/storage/formats/disklabel.py
@@ -229,6 +229,7 @@ class DiskLabel(DeviceFormat):
if not os.access(self.device, os.W_OK):
raise DeviceFormatError("device path does not exist")
+ self.partedDisk.deleteAllPartitions()
self.partedDevice.clobber()
self.commit()
self.exists = False
Thinking about this some more
self.partedDevice.clobber() is what you want:
self.partedDisk.deleteAllPartitions()
^ This removes the partitions from the in memory copy of the table
self.partedDevice.clobber()
^ This will destroy the actual table on the disk
self.commit()
^ This will write the now empty table (but never the less a valid
table) to the disk, undoing the clobber(0.
So we should just call:
self.partedDevice.clobber()
And set partedDisk to None, to indicate the label is gone:
self.partedDisk = None
That's what I tried first, but since udev creates the device nodes for
the partitions, Device.clobber doesn't seem to do anything. After
calling clobber, there's still a disklabel on the device. That's what
led me to use deleteAllPartitions in the first place.
Hmm,
Was this a disk with a gpt table, there is some stuff in libparted about
clobber not clobbering the pmbr, which I find a bit strange.
As for udev, yes that is a different problem, so what we want is:
self.partedDisk.deleteAllPartitions() (*)
self.commit()
self.partedDevice.clobber()
# To get rid of the gpt pmbr which parted preserves
DeviceFormat.destroy(self)
* but then reimplemented in python please, this is a pyparted issue though.
Or we could do a freshdisk here, and commit that.
Regards,
Hans
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list