Skip to main content
Community Scripts logo
Skip to Content
Tools & Add-onsPVE Tools

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, root or swap,
  • 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:

PromptInputEffect
Do you want to delete <lv> (VG: <vg>, Size: <size>)? [y/N]:ylvremove -f <vg>/<lv>
anything elseThe volume is kept.

Environment variables

VariableDefaultPurpose
COMMUNITY_SCRIPTS_CORE_URLhttps://raw.githubusercontent.com/community-scripts/core/mainBase URL the script loads api/api.func from.

Limits

  • lvremove is 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.