Skip to content

Instantly share code, notes, and snippets.

@AnatomicJC
Created August 5, 2025 11:58
Show Gist options
  • Save AnatomicJC/bf3e27ca34b38e9931e9556008b706bb to your computer and use it in GitHub Desktop.
Save AnatomicJC/bf3e27ca34b38e9931e9556008b706bb to your computer and use it in GitHub Desktop.
POOL="rbd"
# 1. Obtenir les ID des images actives
ACTIVE_IDS=$(rbd ls -p "$POOL" --format json | jq -r '.[]' | while read -r img; do
rbd info "$POOL/$img" --format json | jq -r '.block_name_prefix' | cut -d'.' -f2
done)
# 2. Lister tous les objets du pool
rados -p "$POOL" ls > /tmp/all_rbd_objects.txt
# 3. Filtrer les objets data
grep "^rbd_data\." /tmp/all_rbd_objects.txt > /tmp/data_objects.txt
# 4. Vérifier chaque objet : appartient-il à une image active ?
echo "$ACTIVE_IDS" > /tmp/active_ids.txt
echo "🔍 Objets potentiellement orphelins :"
while read -r object; do
ID=$(echo "$object" | cut -d'.' -f2)
if ! grep -q "$ID" /tmp/active_ids.txt; then
echo "$object"
fi
done < /tmp/data_objects.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment