Skip to content

Commit 50ffcd4

Browse files
authored
Feature: Clean Orphan LVM without CEPH (#1974)
1 parent 55c1f2f commit 50ffcd4

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

misc/clean-orphaned-lvm.sh

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,18 @@ function find_orphaned_lvm {
2222

2323
orphaned_volumes=()
2424
while read -r lv vg size; do
25-
container_id=$(echo "$lv" | grep -oE "[0-9]+" | head -1)
26-
27-
# Exclude system-critical LVs
28-
if [[ "$lv" == "data" || "$lv" == "root" || "$lv" == "swap" ]]; then
25+
# Exclude system-critical LVs and Ceph OSDs
26+
if [[ "$lv" == "data" || "$lv" == "root" || "$lv" == "swap" || "$lv" =~ ^osd-block- ]]; then
2927
continue
3028
fi
31-
29+
container_id=$(echo "$lv" | grep -oE "[0-9]+" | head -1)
3230
# Check if the ID exists as a VM or LXC container
3331
if [ -f "/etc/pve/lxc/${container_id}.conf" ] || [ -f "/etc/pve/qemu-server/${container_id}.conf" ]; then
3432
continue
3533
fi
36-
3734
orphaned_volumes+=("$lv" "$vg" "$size")
3835
done < <(lvs --noheadings -o lv_name,vg_name,lv_size --separator ' ' | awk '{print $1, $2, $3}')
3936

40-
if [ ${#orphaned_volumes[@]} -eq 0 ]; then
41-
echo -e "✅ No orphaned LVM volumes found.\n"
42-
exit 0
43-
fi
44-
4537
# Display orphaned volumes
4638
echo -e "❗ The following orphaned LVM volumes were found:\n"
4739
printf "%-25s %-10s %-10s\n" "LV Name" "VG" "Size"

0 commit comments

Comments
 (0)