mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 10:22:50 +00:00 
			
		
		
		
	Feature: Clean Orphan LVM without CEPH (#1974)
This commit is contained in:
		@@ -22,26 +22,18 @@ function find_orphaned_lvm {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    orphaned_volumes=()
 | 
					    orphaned_volumes=()
 | 
				
			||||||
    while read -r lv vg size; do
 | 
					    while read -r lv vg size; do
 | 
				
			||||||
        container_id=$(echo "$lv" | grep -oE "[0-9]+" | head -1)
 | 
					        # Exclude system-critical LVs and Ceph OSDs
 | 
				
			||||||
 | 
					        if [[ "$lv" == "data" || "$lv" == "root" || "$lv" == "swap" || "$lv" =~ ^osd-block- ]]; then
 | 
				
			||||||
        # Exclude system-critical LVs
 | 
					 | 
				
			||||||
        if [[ "$lv" == "data" || "$lv" == "root" || "$lv" == "swap" ]]; then
 | 
					 | 
				
			||||||
            continue
 | 
					            continue
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
 | 
					        container_id=$(echo "$lv" | grep -oE "[0-9]+" | head -1)
 | 
				
			||||||
        # Check if the ID exists as a VM or LXC container
 | 
					        # 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
 | 
					        if [ -f "/etc/pve/lxc/${container_id}.conf" ] || [ -f "/etc/pve/qemu-server/${container_id}.conf" ]; then
 | 
				
			||||||
            continue
 | 
					            continue
 | 
				
			||||||
        fi
 | 
					        fi
 | 
				
			||||||
 | 
					 | 
				
			||||||
        orphaned_volumes+=("$lv" "$vg" "$size")
 | 
					        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 --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
 | 
					    # Display orphaned volumes
 | 
				
			||||||
    echo -e "❗ The following orphaned LVM volumes were found:\n"
 | 
					    echo -e "❗ The following orphaned LVM volumes were found:\n"
 | 
				
			||||||
    printf "%-25s %-10s %-10s\n" "LV Name" "VG" "Size"
 | 
					    printf "%-25s %-10s %-10s\n" "LV Name" "VG" "Size"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user