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]

 



Hi,

On 01/13/2010 12:33 AM, 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 |    2 ++
  1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/storage/formats/disklabel.py b/storage/formats/disklabel.py
index e5fab94..bbc3528 100644
--- a/storage/formats/disklabel.py
+++ b/storage/formats/disklabel.py
@@ -229,6 +229,8 @@ class DiskLabel(DeviceFormat):
          if not os.access(self.device, os.W_OK):
              raise DeviceFormatError("device path does not exist")

+        self._partedDisk = self.freshPartedDisk()
+        self.commit()
          self.partedDevice.clobber()
          self.commit()
          self.exists = False


First of all thanks for avoiding deleteAllPartitions() !

But sorry, I still see some issues with this patch,
self.freshPartedDisk() will create the default label type
for platform, say that that is msdos, but the disk had a gpt
table ? Then on commit only the pmbr will get overwritten,
not the gpt table itself, and when the kernel is asked
to rescan (which is what will remove the partitions from
udev) it will still see a valid gpt table, and most likely
prefer that over the empty msdos one just written.

So:
+       self._partedDisk = self.freshPartedDisk()

Should be:
+       self._partedDisk = parted.freshDisk(device=self.partedDevice, ty=
+                                           self._partedDisk.type)

So that if there is a gpt table, it gets overwritten with an
empty gpt table, and if there is a dos table on an EFI system,
its gets overwritten with an empty dos table, etc.

(note you could make freshPartedDisk() take an optional type
 argument instead of directly calling parted.freshDisk here).

Regards,

Hans

_______________________________________________
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