32 lines
897 B
Bash
Executable file
32 lines
897 B
Bash
Executable file
#!/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
|
|
dd if=/dev/zero of="$DISK" bs=1M count=100
|
|
|
|
# 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
|