Created
July 11, 2016 03:26
-
-
Save brwyatt/5f9c0319d125cd25f3e83964ce58270e to your computer and use it in GitHub Desktop.
Script to out, stop, and remove all (unencrypted) Ceph OSDs and partitions from 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 | |
osds=($(systemctl list-units | grep -iE 'ceph-osd@[[:digit:]]+\.service' | tr -s ' ' | cut -f2 -d' ' | cut -f2 -d'@' | cut -f1 -d'.')) | |
for i in "${osds[@]}"; do | |
echo "***Outing OSD $i" | |
ceph osd out $i | |
done | |
read -p "***Pausing for replication/recovery. Press [ENTER] when done..." $DONE | |
for i in "${osds[@]}"; do | |
echo "***Stopping OSD $i" | |
service ceph-osd@$i stop | |
echo "***Removing OSD $i from CRUSH map" | |
ceph osd crush remove osd.$i | |
echo "***Removing OSD $i from auth list" | |
ceph auth del osd.$i | |
echo "***Removing OSD $i" | |
ceph osd rm $i | |
done | |
echo "***Unmounting OSD dirs" | |
umount /var/lib/ceph/osd/ceph-* | |
echo "***Deleting OSD Data partitions" | |
for p in $(lsblk -okname,parttype,mountpoint | grep '4fbd7e29-9d25-41b8-afd0-062c0ceff05d' | cut -f1 -d' '); do | |
device=${p:0:3} | |
partition=${p:3} | |
parted -s "/dev/${device}" mklabel gpt | |
done | |
echo "***Deleting OSD Journal partitions" | |
for p in $(lsblk -okname,parttype,mountpoint | grep '45b0969e-9b03-4f30-b4c6-b4b80ceff106' | cut -f1 -d' '); do | |
device=${p:0:3} | |
partition=${p:3} | |
parted -s "/dev/${device}" rm "${partition}" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment