Re: [PATCH 1/3] Make sure to clear partitions before destroying a disklabel.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Dave

> 
> 
> Regards,
> 
> Hans
> 
> _______________________________________________
> Anaconda-devel-list mailing list
> Anaconda-devel-list@xxxxxxxxxx
> https://www.redhat.com/mailman/listinfo/anaconda-devel-list


_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux