◉ Pulse
Garfieldttt avatar
#31 today ▲ 37

Garfieldttt/pve-disk-shrink

Shell Tool

A dialog based tool that shrinks a Proxmox VE virtual machine disk.

Created Jul 18, 2026
Stars
18
Today
+7
Forks
1
Quality
80/100
Momentum
35

README

Fetched from GitHub on Nov 7, 2026, 1:37 AM UTC · README.md

View original on GitHub

Third-party content — Open Source Pulse is not the owner of this repository.

This README belongs to Garfieldttt/pve-disk-shrink and its contributors. We fetch it directly from the project’s public GitHub repository and display it for reference only. All text, code, images and trademarks remain the property of their respective authors. See the repository for its license terms. Copyright / takedown policy.

pve-disk-shrink

A dialog based tool that shrinks a Proxmox VE virtual machine disk or LXC container volume completely offline from the host. It replaces the manual GParted procedure: no live ISO, no clicking, no partition editor inside the guest. The whole shrink runs on the PVE node against the stopped guest, which makes it deterministic and repeatable.

It auto discovers the volume, the storage backend and the layout, computes the smallest safe size from the actual data in use, and refuses to make a volume smaller than the data plus a headroom you choose.

What it does

You pick a VM or a container, the disk or volume, and how much to reclaim. The tool then runs the offline sequence that fits the layout:

  • Check the filesystem first (e2fsck for ext, ntfsresize --info for NTFS). Errors are only repaired after you confirm, a dirty or hibernated NTFS is refused.
  • Shrink the filesystem where needed (resize2fs for ext2/3/4, ntfsresize for NTFS).
  • For a partitioned disk, shrink the chosen partition with sgdisk, preserving its start sector, type, name, unique GUID and GPT attribute flags, so root= / /etc/fstab, the Windows boot chain and a Windows Recovery partition keep working. Partitions that sit after it are moved down into the freed space, keeping their order and identity, swap is recreated with its original UUID.
  • Shrink the backing device: zfs set volsize (zvol), qemu-img resize --shrink (qcow2 or raw image), rbd resize --allow-shrink (Ceph/RBD), or lvreduce (LVM). For a ZFS subvol container the dataset refquota is lowered and no filesystem is touched.
  • For a partitioned disk, move the GPT backup header to the new end (sgdisk -e) and verify the table (sgdisk -v).
  • Sync the new size back into the guest config (qm rescan for a VM, the container config for a CT).

Volumes that hold a filesystem or an LVM physical volume directly on the device, with no partition table, are handled too, the partition and GPT steps are then skipped. This is the normal case for containers.

Supported

Guests: QEMU VMs (qm) and LXC containers (pct), listed together.

VM storage backends: ZFS zvol, qcow2 image, raw LV, Ceph/RBD (with KRBD enabled on the storage, so the image maps to /dev/rbd).

Container storage backends: dir/raw image, LVM-thin, ZFS subvol.

Filesystems: ext2/3/4 and NTFS shrink in place. A ZFS subvol is shrunk by its refquota, so its content is never touched.

Layouts:

  • Any GPT layout: you pick which partition to shrink, and any partitions after it are moved down into the freed space while keeping their order, numbering and identity. This covers Windows (C: with a Recovery partition after it) and Linux with extra partitions after root.
  • Reclaim only the free space after the last partition, without touching any filesystem, partition or LVM. This is offered as the safe default whenever such free space exists.
  • Whole disk or container volume with a filesystem directly on it, no partition table.

Guest LVM (an LVM physical volume inside a VM disk) has three modes:

  • Reclaim only the free space after the LVM partition, LVM untouched.
  • Compact: reclaim the volume group's free space with pvmove and pvresize without shrinking any filesystem. Because no filesystem is touched this works with XFS and with mixed volume groups, and handles volume groups that hold several logical volumes.
  • Shrink a filesystem to go below the used size, when a shrinkable ext logical volume exists.

Not supported or handled specially

  • XFS cannot be shrunk. A plain XFS partition is refused. XFS inside an LVM volume group can still be reduced by the group's free space using the compact mode above, since the XFS filesystem itself is never touched.
  • BitLocker (or any encrypted) volumes are detected and never touched. Shrink it in Windows first, or turn BitLocker off there, then re-run this tool. Applies to any encrypted volume.
  • MBR (msdos) partition tables are refused (convert to GPT). A whole disk with no partition table is fine.
  • NTFS must be cleanly shut down, a hibernated volume or Fast Startup is refused.
  • Ceph/RBD is supported only with KRBD enabled (so the image maps to /dev/rbd). A librbd-only volume has no local device and is refused with a hint to enable KRBD.

Requirements

Run it as root on a Proxmox VE node. It uses tools that ship with PVE: qm, pct, pvesm, sgdisk, e2fsck, resize2fs, qemu-nbd, qemu-img, blkid, lsblk, partx, zfs, dialog, numfmt. LVM needs lvm2. NTFS needs ntfs-3g; the tool offers to install it when needed. A Ceph/RBD disk needs rbd (ceph-common), which is already present on any PVE node that serves RBD storage.

Usage

pve-disk-shrink.sh              interactive: pick the guest, the volume and the target size
pve-disk-shrink.sh --dry-run    show the full plan and computed sizes, change nothing
pve-disk-shrink.sh --debug      verbose trace into the logfile

Interactive flow:

  1. Pick the VM or container.
  2. Pick the disk or volume. VM efidisk, tpmstate, cloudinit and CD drives are never listed. For a VM the boot disk is marked [boot].
  3. For a partitioned VM disk, pick the partition to shrink, partitions after it are moved down. This step is skipped for a whole-disk filesystem or a container volume.
  4. If the guest is running you are asked to stop it.
  5. If it has snapshots you are warned that all of them will be deleted permanently, and asked to confirm. Snapshots block a shrink and cannot be kept.
  6. If it has protection set, you are offered to disable it for the shrink. It is re-enabled automatically at the end, including on cancel or error.
  7. Choose how to shrink. Depending on the layout this is a target size (data plus 10, 20, 30, 40 or 50 percent, or a manual size) and, for LVM or when free space follows the last partition, a choice between reclaiming only that free space, compacting, or shrinking a filesystem.
  8. Review the summary and confirm. Nothing is written before this confirmation.

Safety model

  • The guest must be stopped, the volume is worked on offline. You pick the volume explicitly (efidisk, tpmstate, cloudinit and CD drives are never listed).
  • The target can never be smaller than the data in use plus your chosen headroom, nor larger than or equal to the current size.
  • Sizes are parsed in the C locale, so a localized host cannot mis-parse them.
  • The GPT is verified with sgdisk -v after the shrink, a failed check stops the run and tells you not to start the guest.
  • Every destructive step needs explicit confirmation, and a cleanup routine always detaches nbd devices, partition mappings and activated volume groups on exit. --dry-run changes nothing.

This tool creates no backup. Make sure a current backup of the guest exists before you use it.

Recovery

The original partition layout (sgdisk -p) is written to the log before any change, so it can be read back and recreated by hand.

If a run stops with a GPT verification error, do not start the guest: rebuild the backup header with sgdisk -e <device>, then verify with sgdisk -v <device>.

If a guest drops to an emergency shell for a manual filesystem check, run fsck -y /dev/<device> and exit to boot on.

The first boot after a shrink can be slower and may print RCU or lazy-inode warnings while ext4 finishes in the background, this is expected.

Logs

Everything is logged to /var/log/pve-disk-shrink/pve-disk-shrink.log. Bildschirmfoto vom 2026-07-19 16-57-23 Bildschirmfoto vom 2026-07-19 16-57-43 Bildschirmfoto vom 2026-07-19 17-00-52 Bildschirmfoto vom 2026-07-19 16-57-52 Bildschirmfoto vom 2026-07-19 16-57-57 Bildschirmfoto vom 2026-07-19 16-58-08 Bildschirmfoto vom 2026-07-19 17-01-19

Rendered by GitHub from the repository’s README. Scroll to read the full file.
First trending

Jul 19, 2026

first spotted on the list

Best rank

#31

highest position reached

Appearances

3

times on the trending list

Quality score

80

out of 100

Momentum

35

trend strength indicator

Star velocity

0.16

stars per day since creation

Activity — last 60 days

daily counts, collected every 6 hours
  • Stars
  • Forks
  • Merged PRs
  • Issues
  • Closed issues

Collecting activity data since launch — check back in a few days.

Star history

total stars per snapshot
8101214161820Garfieldttt/pve-disk-shrink · Jul 19, 8 AM UTC: 10 starsGarfieldttt/pve-disk-shrink · Jul 19, 1 PM UTC: 11 starsGarfieldttt/pve-disk-shrink · Jul 19, 7 PM UTC: 18 stars8 AM1 PM7 PM

Rank history

position on trending · lower is better
#1#30#35#40#45#50#55#60#65Jul 19, 8 AM UTC: rank #32Jul 19, 1 PM UTC: rank #61Jul 19, 7 PM UTC: rank #318 AM1 PM7 PM

3D card for your website

Live HTML card with a glass surface and pointer tilt. Paste the iframe on any website.

<iframe src="https://www.notionpulse.cc/embed/Garfieldttt/pve-disk-shrink" width="420" height="240" style="border:0;max-width:100%;background:transparent" loading="lazy" title="Garfieldttt/pve-disk-shrink — trending on Open Source Pulse"></iframe>

Stars badge

Show current stars in your README or profile. Auto-updates every 6 hours.

Garfieldttt/pve-disk-shrink stars badge
Markdown
[![Garfieldttt/pve-disk-shrink](https://www.notionpulse.cc/api/badge/Garfieldttt/pve-disk-shrink.svg)](https://www.notionpulse.cc/repo/Garfieldttt/pve-disk-shrink)
HTML
<a href="https://www.notionpulse.cc/repo/Garfieldttt/pve-disk-shrink"><img src="https://www.notionpulse.cc/api/badge/Garfieldttt/pve-disk-shrink.svg" alt="Garfieldttt/pve-disk-shrink stars badge" /></a>

Repository of the Day

#31 Repository of the Day

Repository of the Week

#31 Repository of the Week

Repository of the Month

#31 Repository of the Month