2021-10-18 11:53:38 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Inspired from https://rook.io/docs/rook/v1.7/ceph-teardown.html
|
|
|
|
|
|
|
|
if [ $# -ne 1 ]; then
|
|
|
|
echo $0 disk
|
|
|
|
echo f.i. $0 /dev/sdx
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
DISK="$1"; shift
|
|
|
|
|
|
|
|
# Zap the disk to a fresh, usable state (zap-all is important, b/c MBR has to be clean)
|
|
|
|
|
|
|
|
# You will have to run this step for all disks.
|
|
|
|
sgdisk --zap-all $DISK
|
|
|
|
|
|
|
|
# Clean hdds with dd
|
2021-10-18 12:29:05 +00:00
|
|
|
dd if=/dev/zero of="$DISK" bs=1M count=100
|
2021-10-18 11:53:38 +00:00
|
|
|
|
|
|
|
# Clean disks such as ssd with blkdiscard instead of dd
|
|
|
|
blkdiscard $DISK
|
|
|
|
|
|
|
|
# These steps only have to be run once on each node
|
|
|
|
# If rook sets up osds using ceph-volume, teardown leaves some devices mapped that lock the disks.
|
|
|
|
ls /dev/mapper/ceph-* | xargs -I% -- dmsetup remove %
|
|
|
|
|
|
|
|
# ceph-volume setup can leave ceph-<UUID> directories in /dev and /dev/mapper (unnecessary clutter)
|
|
|
|
rm -rf /dev/ceph-*
|
|
|
|
rm -rf /dev/mapper/ceph--*
|
|
|
|
|
|
|
|
# Inform the OS of partition table changes
|
|
|
|
partprobe $DISK
|