PVE Clean Orphaned LVM
Find LVM logical volumes whose VM or container no longer exists and delete them one by one after confirmation.
When a guest is removed but its disk is not, the logical volume stays behind and occupies space. clean-orphaned-lvm.sh lists such volumes and asks for each one whether to delete it.
Website entry: clean-orphaned-lvm. Source: tools/pve/clean-orphaned-lvm.sh.
Run
In the Proxmox VE host shell, as root:
bash -c "$(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/tools/pve/clean-orphaned-lvm.sh)"There is no start confirmation. The scan runs immediately; nothing is deleted before you answer a prompt.
How a volume is judged
The script reads all logical volumes with lvs and skips:
- volumes named
data,rootorswap, - volumes whose name starts with
osd-block-(Ceph OSDs), - thin pools (segment type
thin-pool).
From each remaining volume name it takes the first number, for example 105 from vm-105-disk-0. If /etc/pve/nodes/*/lxc/<number>.conf or /etc/pve/nodes/*/qemu-server/<number>.conf exists on any cluster node, the volume belongs to a guest and is skipped. Everything else is listed as orphaned with name, volume group and size.
Prompt
For each listed volume:
| Prompt | Input | Effect |
|---|---|---|
Do you want to delete <lv> (VG: <vg>, Size: <size>)? [y/N]: | y | lvremove -f <vg>/<lv> |
| anything else | The volume is kept. |
Environment variables
| Variable | Default | Purpose |
|---|---|---|
COMMUNITY_SCRIPTS_CORE_URL | https://raw.githubusercontent.com/community-scripts/core/main | Base URL the script loads api/api.func from. |
Limits
lvremoveis final. There is no undo.- The test is the name only. A volume you created yourself whose name contains no guest ID, or a number that matches no guest, is listed as orphaned. Read each prompt before you answer
y. - A volume of a deleted guest is not found if another guest now uses the same ID.
- Only LVM is covered. ZFS datasets, directory storage and Ceph images are not scanned.
- The heading "The following orphaned LVM volumes were found" is printed even when the list is empty.