mirror of
https://github.com/community-scripts/ProxmoxVE
synced 2025-02-04 15:00:16 +00:00
Feature: Clean Orphan LVM without CEPH (#1974)
This commit is contained in:
parent
55c1f2f3dc
commit
50ffcd4734
@ -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"
|
||||
|
Loading…
Reference in New Issue
Block a user