[pve-devel] [PATCH storage 04/10] diskmanage: wipe blockdev: also change partition type

Fabian Ebner f.ebner at proxmox.com
Tue Sep 28 13:39:44 CEST 2021


when called with a partition. Since get_disks uses the partition type
(among other things) to detect LVM and ZFS volumes, such volumes would
still be seen as in-use after wiping. Thus, also change the partition
type and simply use 0x83 "Linux filesystem".

Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
 PVE/Diskmanage.pm | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/PVE/Diskmanage.pm b/PVE/Diskmanage.pm
index 3fea649..5614e40 100644
--- a/PVE/Diskmanage.pm
+++ b/PVE/Diskmanage.pm
@@ -913,6 +913,7 @@ sub change_parttype {
 }
 
 # Wipes all labels and the first 200 MiB of a disk/partition (or the whole if it is smaller).
+# If called with a partition, also sets the partition type to 0x83 'Linux filesystem'.
 # Expected to be called with a result of verify_blockdev_path().
 sub wipe_blockdev {
     my ($devpath) = @_;
@@ -945,6 +946,11 @@ sub wipe_blockdev {
 	['dd', 'if=/dev/zero', "of=${devpath}", 'bs=1M', 'conv=fdatasync', "count=${count}"],
 	errmsg => "error wiping '${devpath}'",
     );
+
+    if (is_partition($devpath)) {
+	eval { change_parttype($devpath, '8300'); };
+	warn $@ if $@;
+    }
 }
 
 1;
-- 
2.30.2






More information about the pve-devel mailing list