]> git.proxmox.com Git - pve-storage.git/commitdiff
disks: wipe blockdev: pass all child partitions to wipefs
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 2 Jun 2021 11:13:26 +0000 (13:13 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 2 Jun 2021 11:13:26 +0000 (13:13 +0200)
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
PVE/Diskmanage.pm

index e81692d3ca8e30243de35172c6b8479e58600d66..6db527914e64ab3a59fd33d75969cc45e7f2f16a 100644 (file)
@@ -909,9 +909,20 @@ sub wipe_blockdev {
     my $size = ($dev_size * 512 / 1024 / 1024);
     my $count = ($size < 200) ? $size : 200;
 
-    print "wiping disk/partition: ${devpath}\n";
+    my $to_wipe = [];
+    dir_glob_foreach("/sys/class/block/${devname}", "${devname}.+", sub {
+       my ($part) = @_;
+       push $to_wipe->@*, "/dev/${part}" if -b "/dev/${part}";
+    });
+
+    if (scalar($to_wipe->$#*) > 0) {
+       print "found child partitions to wipe: ". join($to_wipe->@*, ',') ."\n";
+    }
+    push $to_wipe->@*, $devpath; # put actual device last
+
+    print "wiping block device ${devpath}\n";
 
-    run_command(['wipefs', '--all', $devpath], errmsg => "error wiping '${devpath}'");
+    run_command(['wipefs', '--all', $to_wipe->@*], errmsg => "error wiping '${devpath}'");
 
     run_command(
        ['dd', 'if=/dev/zero', "of=${devpath}", 'bs=1M', 'conv=fdatasync', "count=${count}"],