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';
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};
# 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 {
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 {
}
# Wipes all labels and the first 200 MiB of a disk/partition (or the whole if it is smaller).
+# If called with a partition, also sets the partition type to 0x83 'Linux filesystem'.
# Expected to be called with a result of verify_blockdev_path().
sub wipe_blockdev {
my ($devpath) = @_;
['dd', 'if=/dev/zero', "of=${devpath}", 'bs=1M', 'conv=fdatasync', "count=${count}"],
errmsg => "error wiping '${devpath}'",
);
+
+ if (is_partition($devpath)) {
+ eval { change_parttype($devpath, '8300'); };
+ warn $@ if $@;
+ }
}
1;