ZFS ZVOL for Virtual Machines

norsemangrey

Member
Feb 8, 2021
63
9
13
39
I have been reading the OpenZFS Performance and Tuning document and came across this section:

Virtual machines

Virtual machine images on ZFS should be stored using either zvols or raw files to avoid unnecessary overhead. The recordsize/volblocksize and guest filesystem should be configured to match to avoid overhead from partial record modification. This would typically be 4K. If raw files are used, a separate dataset should be used to make it easy to configure recordsize independently of other things stored on ZFS.

In practice, how is this done in Proxmox? Lets say I have a a couple of dedicated SSDs for VMs/LXCs configured in a ZFS mirror. How do I create a new VM storing it on a ZVOL and what will be the virtual / VM file system?
 
While Linux guests usually have no problem with the default 8k block size, Windows guests can get a bit better performance if the ZVOLs for their disks are created with a block size of 4k.

The block size is set when the zvol is created. The default value is stored in the PVE storage configuration for that storage. So you could just set that to 4k and every new VM disk will be created with 4k.

For already existing disks you will have to recreate them. Either by restoring from backup or by temporarily moving the disk to another storage. When moving the disk back to the ZFS storage, the zvol will be created again with the new value for the block size.

You could also create a new dataset and configure a dedicated PVE storage there with a different block size.


To see which block size is used for a zvol: zfs get volblocksize <pool>/<dataset path>
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!