]> git.proxmox.com Git - pve-storage.git/blobdiff - PVE/Diskmanage.pm
pbs: integrate support for protected
[pve-storage.git] / PVE / Diskmanage.pm
index 5041fb393f20670a2c9c94223eb492a41cb52cc8..18459f95291a5f70af8c051d49208cb7705fee71 100644 (file)
@@ -63,8 +63,8 @@ sub init_disk {
 
     assert_blockdev($disk);
 
-    # we should already have checked if it is in use in the api call
-    # but we check again for safety
+    # we should already have checked these in the api call, but we check again for safety
+    die "$disk is a partition\n" if is_partition($disk);
     die "disk $disk is already in use\n" if disk_is_used($disk);
 
     my $id = $uuid || 'R';
@@ -78,7 +78,7 @@ sub disk_is_used {
     my $dev = $disk;
     $dev =~ s|^/dev/||;
 
-    my $disklist = get_disks($dev, 1);
+    my $disklist = get_disks($dev, 1, 1);
 
     die "'$disk' is not a valid local disk\n" if !defined($disklist->{$dev});
     return 1 if $disklist->{$dev}->{used};
@@ -661,7 +661,7 @@ sub get_disks {
            # for devices, this check is done explicitly later
            return 'Device Mapper' if !dir_is_empty("$sysdir/holders");
 
-           return 'partition';
+           return; # unused partition
        };
 
        my $collect_ceph_info = sub {
@@ -730,7 +730,6 @@ sub get_disks {
        my $used = $determine_usage->($devpath, $sysdir, 0);
        if (!$include_partitions) {
            foreach my $part (sort keys %{$partitions}) {
-               next if $partitions->{$part}->{used} eq 'partition';
                $used //= $partitions->{$part}->{used};
            }
        } else {