Linux VPS

ZFS storage for virtual machines: pools, zvols and tuning

Use ZFS to store KVM and Proxmox virtual machine disks: choose a pool layout, create zvols, set compression and volblocksize, plan RAM for ARC and use snapshots and replication.

AdvancedKVM and Proxmox hosts2 min read

ZFS combines a volume manager and filesystem with checksums, compression, snapshots and replication. That makes ZFS storage for virtual machines popular on Proxmox VE, VirtFusion and plain KVM hosts. This guide covers the decisions that matter for VM performance and safety.

Before you start

  • A Linux host with OpenZFS installed (sudo apt install zfsutils-linux on Ubuntu; built into Proxmox VE).
  • Dedicated disks for the pool, ideally NVMe or enterprise SSDs. Disks are wiped when added.
  • Plenty of RAM; ZFS uses it for the ARC read cache.

Choose a pool layout

LayoutRedundancyVM performance
Mirror (2-way)Survives 1 disk per mirrorBest random I/O, recommended for VMs
Striped mirrors (RAID10)1 disk per mirror vdevExcellent; scales with vdevs
RAIDZ1/21 or 2 disks per vdevMore usable space, weaker random I/O

Create a mirror pool using stable disk IDs:

zpool create -o ashift=12 vmpool mirror /dev/disk/by-id/nvme-DISK1 /dev/disk/by-id/nvme-DISK2

Set dataset defaults

zfs set compression=lz4 vmpool
zfs set atime=off vmpool

lz4 compression is cheap and usually increases effective throughput.

Create zvols for VM disks

A zvol is a block device backed by ZFS, used as a raw VM disk:

zfs create -s -V 50G -o volblocksize=16k vmpool/vm-101-disk-0
  • -s makes it sparse (thin provisioned).
  • volblocksize is fixed at creation. 16k is a common default; databases may prefer matching their page size.
  • Attach /dev/zvol/vmpool/vm-101-disk-0 to the VM as a raw virtio disk.

Proxmox and VirtFusion create zvols for you when you add a ZFS storage; see VirtFusion storage.

Plan RAM for the ARC

ARC defaults to a large share of RAM. On a VM host, cap it so guests have memory:

echo "options zfs zfs_arc_max=8589934592" | sudo tee /etc/modprobe.d/zfs.conf

That caps ARC at 8 GiB after reboot (update the initramfs on Debian-based systems).

Snapshots and replication

zfs snapshot vmpool/vm-101-disk-0@before-upgrade
zfs send -i @snap1 vmpool/vm-101-disk-0@snap2 | ssh backup zfs receive backup/vm-101

Incremental send/receive copies only changed blocks to another host, a strong base for off-site backups.

Troubleshooting

  • Pool slow when nearly full: keep usage under about 80%.
  • Host out of memory: lower zfs_arc_max.
  • Degraded pool: check zpool status and replace the failed disk with zpool replace.

Frequently asked questions

Do I need ECC RAM for ZFS?

Recommended for servers, as with any filesystem, but ZFS works without it.

ZFS or LVM-thin for VMs?

LVM-thin is lighter on RAM; ZFS adds checksums, compression and replication. See VM disk formats.

Should I add an SLOG or L2ARC?

Only after measuring. An SLOG helps sync-heavy writes; L2ARC helps when the working set exceeds RAM.

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.