I’ve created a LVM (eg. “vg1”) and set the whole space to a single group (eg. “vz”) to have plenty room for my Proxmox VMs (space directive “all” at LVM creation).

LV vg1 vz /var/lib/vz ext4 all

Upon taking cron based snapshots of running VMs, Proxmox said that there’s no space left on vg1.

I’ve got the following errors in the snapshot logs:

INFO: Volume group "vg1" has insufficient free space (0 extents): 256 required.
ERROR: Backup of VM 123 failed - command 'lvcreate --size 1024M --snapshot --name 'vzsnap-virtual-0' '/dev/vg1/vz'' failed: exit code 5

LVM util “vgs vg1” shows:

root@proxmox ~ # vgs vg1
 VG #PV #LV #SN Attr VSize VFree
 vg1 1 1 0 wz--n- 1.73t 0

Look at the value of VFree. Looks bad, 0 bytes free!

Backup all your data on your LVM VG to be shrinked before proceeding!

  • Shutdown all VMs
  • Stop Proxmox
  • Stop all KVM processes

Unmount the vg1 LVM VG:

umount /dev/vg1/vz

You need to check the filesystem on the LVM device first:

e2fsck -f /dev/vg1/vz

After that’s passed, shrink the filesystem on vg1/vz:

resize2fs /dev/vg1/vz NEWVAL[KMG]

In my case that did the job:

root@proxmox ~ # resize2fs /dev/vg1/vz 1200G
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/vg1/vz to 314572800 (4k) blocks.
The filesystem on /dev/vg1/vz is now 314572800 blocks long.

The new shrinked block size on /dev/vg1/vz is now 314572800 blocks.

Let’s check if the blocksize matches by remounting the shrinked filesystem:

mount /dev/vg1/vz

Get an approximate block count for the shrinked filesystem:

root@proxmox ~ # df /var/lib/vz
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mapper/vg1-vz 1248378224 15409856 1170053812 2% /var/lib/vz
root@proxmox ~ # df -h /var/lib/vz
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg1-vz 1.2T 15G 1.1T 2% /var/lib/vz

Looks good. The value of 1K blocks is a bit lower than the actual block size of the whole filesystem. That’s normal.

Verify the exact block size (LVM does not need to be mounted):

root@proxmox ~ # dumpe2fs -h /dev/vg1/vz|grep "Block count"
dumpe2fs 1.41.12 (17-May-2010)
Block count: 314572800

Looks good. Block count 314572800 matches the block count that resize2fs printed after shrinking.

Unmount filesystem!

umount /dev/vg1/vz

Resizing the LVM:

root@proxmox ~ # lvreduce --size 1200G /dev/vg1/vz
 WARNING: Reducing active and open logical volume to 1.17 TiB
 THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce vz? [y/n]: y
 Reducing logical volume vz to 1.17 TiB
 Logical volume vz successfully resized

Final check:

root@virtual ~ # vgs vg1
 VG #PV #LV #SN Attr VSize VFree
 vg1 1 1 0 wz--n- 1.73t 566.52g
VFree tells me that there are 566.52G free. Looks good.
Check shrinked filesystem: 
root@proxmox ~ # e2fsck -f /dev/vg1/vz
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vg1/vz: 37/78643200 files (0.0% non-contiguous), 6330708/314572800 blocks
Remount the shrinked filesystem:
root@proxmox ~ # mount /dev/mapper/vg1-vz
Check space on shrinked filesystem:
root@proxmox ~ # df -h /var/lib/vz
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg1-vz 1.2T 15G 1.1T 2% /var/lib/vz

Well. We’re done!

Benjamin Wiedmann

Benjamin Wiedmann is an IT Professional, Software Developer, Photograph and Musician. Read more...

More Posts - Website

Follow Me:
TwitterLinkedInGoogle Plus