mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-06 17:10:35 +00:00
add wipe_disk option when destroying ceph disk
this allows the disk to be reused as ceph disk by zeroing the first 200M of the destroyed disk. disks are iterated separately from partitions to prevent duplicate wipes. Signed-off-by: David Limbeck <d.limbeck@proxmox.com>
This commit is contained in:
parent
5d4bb1f732
commit
1b3caf4f21
@ -397,6 +397,7 @@ __PACKAGE__->register_method ({
|
||||
# try to unmount from standard mount point
|
||||
my $mountpoint = "/var/lib/ceph/osd/ceph-$osdid";
|
||||
|
||||
my $disks_to_wipe = {};
|
||||
my $remove_partition = sub {
|
||||
my ($part) = @_;
|
||||
|
||||
@ -407,6 +408,8 @@ __PACKAGE__->register_method ({
|
||||
print "remove partition $part (disk '${devpath}', partnum $partnum)\n";
|
||||
eval { run_command(['/sbin/sgdisk', '-d', $partnum, "${devpath}"]); };
|
||||
warn $@ if $@;
|
||||
|
||||
$disks_to_wipe->{$devpath} = 1;
|
||||
};
|
||||
|
||||
my $partitions_to_remove = [];
|
||||
@ -434,6 +437,7 @@ __PACKAGE__->register_method ({
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
print "Unmount OSD $osdsection from $mountpoint\n";
|
||||
eval { run_command(['/bin/umount', $mountpoint]); };
|
||||
if (my $err = $@) {
|
||||
@ -443,6 +447,11 @@ __PACKAGE__->register_method ({
|
||||
foreach my $part (@$partitions_to_remove) {
|
||||
$remove_partition->($part);
|
||||
}
|
||||
foreach my $devpath (keys %$disks_to_wipe) {
|
||||
print "wipe disk: $devpath\n";
|
||||
eval { run_command(['/bin/dd', 'if=/dev/zero', "of=${devpath}", 'bs=1M', 'count=200', 'conv=fdatasync']); };
|
||||
warn $@ if $@;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user