[pve-devel] [PATCH storage 2/2] Fix #2550: Wipe disks before creating a directory

Dominic Jäger d.jaeger at proxmox.com
Mon Jan 27 13:38:41 CET 2020


Necessary because leftovers on a disk can make partitioning it fail.

Signed-off-by: Dominic Jäger <d.jaeger at proxmox.com>
---
 PVE/API2/Disks/Directory.pm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/Disks/Directory.pm b/PVE/API2/Disks/Directory.pm
index 4c74776..8a317d3 100644
--- a/PVE/API2/Disks/Directory.pm
+++ b/PVE/API2/Disks/Directory.pm
@@ -236,8 +236,15 @@ __PACKAGE__->register_method ({
 	    my $mountunitpath = "/etc/systemd/system/$mountunitname";
 
 	    PVE::Diskmanage::locked_disk_action(sub {
+		# Leftovers might thwart partitioning
+		my $cmd = ['/sbin/wipefs', '-a', $dev];
+		print "# ", join(' ', @$cmd), "\n";
+		run_command($cmd);
+
+		PVE::Diskmanage::wipe_disks($dev);
+
 		# create partition
-		my $cmd = [$SGDISK, '-n1', '-t1:8300', $dev];
+		$cmd = [$SGDISK, '-n1', '-t1:8300', $dev];
 		print "# ", join(' ', @$cmd), "\n";
 		run_command($cmd);
 
-- 
2.20.1




More information about the pve-devel mailing list