From 50ffcd4734d5adbdf8a72b14fec9c3769c2bde6b Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Mon, 3 Feb 2025 11:57:39 +0100 Subject: [PATCH] Feature: Clean Orphan LVM without CEPH (#1974) --- misc/clean-orphaned-lvm.sh | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/misc/clean-orphaned-lvm.sh b/misc/clean-orphaned-lvm.sh index d8ad7820..533ef50e 100644 --- a/misc/clean-orphaned-lvm.sh +++ b/misc/clean-orphaned-lvm.sh @@ -22,26 +22,18 @@ function find_orphaned_lvm { orphaned_volumes=() while read -r lv vg size; do - container_id=$(echo "$lv" | grep -oE "[0-9]+" | head -1) - - # Exclude system-critical LVs - if [[ "$lv" == "data" || "$lv" == "root" || "$lv" == "swap" ]]; then + # Exclude system-critical LVs and Ceph OSDs + if [[ "$lv" == "data" || "$lv" == "root" || "$lv" == "swap" || "$lv" =~ ^osd-block- ]]; then continue fi - + container_id=$(echo "$lv" | grep -oE "[0-9]+" | head -1) # Check if the ID exists as a VM or LXC container if [ -f "/etc/pve/lxc/${container_id}.conf" ] || [ -f "/etc/pve/qemu-server/${container_id}.conf" ]; then continue fi - orphaned_volumes+=("$lv" "$vg" "$size") done < <(lvs --noheadings -o lv_name,vg_name,lv_size --separator ' ' | awk '{print $1, $2, $3}') - if [ ${#orphaned_volumes[@]} -eq 0 ]; then - echo -e "✅ No orphaned LVM volumes found.\n" - exit 0 - fi - # Display orphaned volumes echo -e "❗ The following orphaned LVM volumes were found:\n" printf "%-25s %-10s %-10s\n" "LV Name" "VG" "Size"