Factoring the wipe_disk out into CephTools

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
This commit is contained in:
Alwin Antreich 2018-11-27 16:02:56 +01:00 committed by Thomas Lamprecht
parent cccaf366a2
commit b4bf4a376f
2 changed files with 16 additions and 6 deletions

View File

@ -312,6 +312,7 @@ __PACKAGE__->register_method ({
}
}
PVE::CephTools::wipe_disk($devpath);
run_command($cmd);
};
@ -439,12 +440,8 @@ __PACKAGE__->register_method ({
foreach my $part (@$partitions_to_remove) {
$remove_partition->($part);
}
my @wipe_cmd = qw(/bin/dd if=/dev/zero bs=1M count=200 conv=fdatasync);
foreach my $devpath (keys %$disks_to_wipe) {
print "wipe disk: $devpath\n";
eval { run_command([@wipe_cmd, "of=${devpath}"]) };
warn $@ if $@;
}
PVE::CephTools::wipe_disk(keys %$disks_to_wipe);
}
};

View File

@ -469,4 +469,17 @@ sub destroy_mds {
return undef;
};
# wipe the first 200 MB to clear off leftovers from previous use, otherwise a
# create OSD fails.
sub wipe_disk {
my (@devs) = @_;
my @wipe_cmd = qw(/bin/dd if=/dev/zero bs=1M count=200 conv=fdatasync);
foreach my $devpath (values @devs) {
print "wipe disk: $devpath\n";
eval { run_command([@wipe_cmd, "of=${devpath}"]) };
warn $@ if $@;
}
};
1;