Last active
January 30, 2018 12:06
-
-
Save wido/4a8539b49956fcaaae8db3ae0658102b to your computer and use it in GitHub Desktop.
Stop, umount and wipe all Ceph OSDs on a system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
systemctl stop ceph-osd.target | |
for ID in $(df -P|grep "/var/lib/ceph/osd"|awk '{print $6}'|cut -d '-' -f 2); do | |
DEVICE=$(df -P /var/lib/ceph/osd/ceph-$ID|awk '{print $1}'|tail -1|sed 's/.$//'|cut -d '/' -f 3) | |
ROTATIONAL=$(cat /sys/block/$DEVICE/queue/rotational) | |
echo "Stopping osd.$ID" | |
systemctl stop ceph-osd@$ID | |
umount /var/lib/ceph/osd/ceph-$ID | |
if [ "$ROTATIONAL" -eq 0 ]; then | |
echo "Issuing a blkdiscard for $DEVICE" | |
blkdiscard /dev/$DEVICE | |
else | |
echo "Zapping device $DEVICE" | |
ceph-disk zap /dev/$DEVICE | |
fi | |
blockdev --rereadpt /dev/$DEVICE | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment