Fix/thinpool detection as it allows to delete active thinpool with different name than "data" (#6730)

* Fix: exclude all thin-pools dynamically instead of only 'data'

* Fix: dynamically exclude all thin pools (not just 'data') from orphan check

* Fix: dynamically exclude all thin pools (not just 'data') from orphan check
This commit is contained in:
Florian Kefferpütz 2025-08-10 13:37:49 +02:00 committed by GitHub
parent c60f04e229
commit 4258d44a7d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,18 +21,25 @@ function find_orphaned_lvm {
echo -e "\n🔍 Scanning for orphaned LVM volumes...\n"
orphaned_volumes=()
while read -r lv vg size; do
while read -r lv vg size seg_type; do
# Exclude system-critical LVs and Ceph OSDs
if [[ "$lv" == "data" || "$lv" == "root" || "$lv" == "swap" || "$lv" =~ ^osd-block- ]]; then
continue
fi
# Exclude thin pools (any name)
if [[ "$seg_type" == "thin-pool" ]]; 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}')
done < <(lvs --noheadings -o lv_name,vg_name,lv_size,seg_type --separator ' ' 2>/dev/null | awk '{print $1, $2, $3, $4}')
# Display orphaned volumes
echo -e "❗ The following orphaned LVM volumes were found:\n"