Linux VPS

Use LVM as a storage pool for KVM virtual machines

Create an LVM volume group for KVM, define it as a libvirt storage pool, create logical volumes for VM disks, use LVM-thin for overprovisioning and resize or snapshot VM volumes.

IntermediateKVM hosts2 min read

Storing VM disks as LVM logical volumes avoids a filesystem layer and gives fast, predictable block I/O. This guide shows how to set up an LVM storage pool for KVM with libvirt, the same approach many VPS panels use under the hood.

Before you start

Create the volume group

pvcreate /dev/nvme1n1
vgcreate vg_vms /dev/nvme1n1

Check with vgs.

Define it as a libvirt pool

virsh pool-define-as vg_vms logical --source-name vg_vms --target /dev/vg_vms
virsh pool-start vg_vms
virsh pool-autostart vg_vms

Confirm with virsh pool-info vg_vms.

Create VM disks

virsh vol-create-as vg_vms web01-disk0 40G

Use it with virt-install:

virt-install --name web01 --memory 4096 --vcpus 2 --disk vol=vg_vms/web01-disk0,bus=virtio --cdrom /var/lib/libvirt/images/debian-12.iso --os-variant debian12 --network bridge=br0,model=virtio --graphics vnc,listen=127.0.0.1 --noautoconsole

See create a VM with virt-install for the full workflow.

Thin provisioning with LVM-thin

Plain logical volumes reserve their whole size. LVM-thin allocates space only as written, allowing overprovisioning:

lvcreate --type thin-pool -l 95%FREE -n thinpool vg_vms
lvcreate -V 40G --thin -n web02-disk0 vg_vms/thinpool

libvirt's logical pool type does not create thin volumes itself; create them with lvcreate and attach the path /dev/vg_vms/web02-disk0. Monitor thin pool usage closely with lvs: a full thin pool can corrupt VMs. Proxmox and VPS panels manage LVM-thin natively; see Virtualizor LVM-thin.

Resize a VM disk

lvextend -L +20G /dev/vg_vms/web01-disk0

Then tell the running VM: virsh blockresize web01 /dev/vg_vms/web01-disk0 60G, and grow the partition and filesystem inside the guest.

Snapshots

lvcreate -s -L 5G -n web01-snap /dev/vg_vms/web01-disk0

Classic LVM snapshots slow writes and fail when their space fills, so keep them short-lived (for example during a backup). Thin snapshots are cheaper.

Troubleshooting

  • Pool will not start: the volume group name or target path is wrong; check vgs and virsh pool-dumpxml.
  • Thin pool 100% full: extend it immediately with lvextend and add disks; set autoextend in lvm.conf.
  • VM sees old size after resize: run blockresize or reboot the guest.

Frequently asked questions

LVM or qcow2 files?

LVM is faster and simpler for block I/O; qcow2 is more portable and has internal snapshots. See qcow2 vs raw.

Can I use LVM on RAID?

Yes. Put the physical volume on an mdadm or hardware RAID device for redundancy.

LVM-thin or ZFS?

LVM-thin uses less RAM; ZFS adds checksums and compression. See ZFS for VMs.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.