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

Signed-off-by: Dominic Jäger <d.jae...@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

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to