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

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Jan 27 15:57:19 CET 2020


On January 27, 2020 1:38 pm, Dominic Jäger wrote:
> Necessary because leftovers on a disk can make partitioning it fail.

shouldn't those leftovers be detected by our "is disk in use" checks? 
what's missing there?

> 
> 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);

would it make sense to (optionally) include wipefs into wipe_disks?
> +
> +		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 at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>




More information about the pve-devel mailing list