remote-backups.comremote-backups.com
Contact illustration
Sign In
Don't have an account ?Sign Up

ZFS RAIDZ Usable Capacity for a PBS Datastore

You buy six 4 TB disks for a Proxmox Backup Server datastore and build a RAIDZ2 pool. You expect 16 TB, but zfs list shows less, and the number does not match zpool list either. This post explains the parity rule, where the rest of the space goes, and how much space to plan for backup data.

Key Takeaways
  • A RAIDZ vdev of N disks with P parity disks holds about (N-P) times the disk size. A 2-way mirror holds 50% of its disks.
  • Real usable space is lower: disk makers count in powers of 1000, ZFS shows powers of 1024, small blocks need extra parity, and ZFS keeps a reserve of up to 128 GiB.
  • Chunk files in a Proxmox Backup Server datastore are often much larger than the default recordsize of 128K, so the parity rule fits a datastore better than a pool of VM disks.
  • A special device stores metadata. Give it the same redundancy as the pool, because the loss of the special device loses the pool.
  • Keep at least 10% of the pool free. Pruned backups free space only after garbage collection.
General ZFS facts

This post describes general OpenZFS behavior, with sources from the OpenZFS, Proxmox VE and PBS documentation. It does not describe the pool layout of remote-backups.com.

The basic rule: N minus P

The OpenZFS documentation gives the rule for RAIDZ: a group of N disks of size X with P parity disks holds about (N-P) × X bytes and survives P failed disks. RAIDZ1 has one parity disk, RAIDZ2 has two and RAIDZ3 has three. A RAIDZ group needs at least P+1 disks. OpenZFS recommends 3 to 9 disks per group.

A mirror vdev stores a full copy of the data on each disk. A 2-way mirror gives 50% of its disks as usable space, and a 3-way mirror gives 33%. A pool of several vdevs adds their space together.

For six 4 TB disks (24 TB raw), the rule gives these values:

LayoutUsable (parity rule)Disks that can fail
RAIDZ1, one vdev of 6 disks20 TB1
RAIDZ2, one vdev of 6 disks16 TB2
RAIDZ3, one vdev of 6 disks12 TB3
Three 2-way mirrors12 TB1 per mirror
Two 3-way mirrors8 TB2 per mirror

The Proxmox VE documentation names one special case: with 4 disks, RAIDZ2 and two 2-way mirrors give the same usable space. The mirrors give better performance, so they are usually the better choice.

You can try other disk counts and sizes in our ZFS calculator. It applies the same parity rule. It does not subtract padding, reserved space or metadata, so use its result as the upper limit. The calculator labels its unit TB, but it counts 1 TB as 1024^4 bytes (1 TiB). For a 4 TB disk, enter 3.64 in the TB field and read the result as TiB. In the calculator, "Mirror" means one mirror vdev with all disks. For several 2-way mirrors, count one disk per mirror.

Why the real number is lower

Units

Disk makers count 1 TB as 10^12 bytes. ZFS tools count in powers of 1024 (the zfsprops man page treats 1536M and 1.5G as equal). A 4 TB disk is about 3.64 TiB. The 16 TB RAIDZ2 pool from the table shows as about 14.55 TiB before any other overhead.

Parity and padding per block

The (N-P) rule is an approximation. ZFS writes parity per block, not per disk. The smallest write unit is one sector, which the ashift of the vdev sets (ashift=12 means 4K sectors). The OpenZFS RAIDZ page gives two examples for a RAIDZ1 of 3 disks with ashift=12:

  • With recordsize=4K, each 4K data block gets one 4K parity block. The usable ratio is 50%, the same as a 2-way mirror.
  • With recordsize=128K, ZFS writes 16 stripes with 8K of data and 4K of parity each. It writes 192K to store 128K, so the usable ratio is 66%. This matches the (N-P)/N rule.

The Proxmox VE documentation shows the same effect for VM disks: a ZVOL with the default 8K block size on RAIDZ2 with ashift=12 writes 8K + 4K + 4K = 16K for each 8K block. Small blocks on RAIDZ cost much more space than the parity rule suggests. Large blocks come close to the rule.

Reserved space (slop)

ZFS keeps the last part of the pool free so that the pool never runs completely out of space. The OpenZFS module parameter spa_slop_shift controls this reserve. With the default value, ZFS reserves about 3.2% of the pool, with a minimum of 128 MiB and a maximum of 128 GiB. On a pool larger than about 4 TiB, the reserve is the maximum of 128 GiB. When the free space falls below this reserve, most writes fail with "no space".

Metadata

Every file needs metadata: block pointers, directory entries and the space maps of the pool. A datastore with millions of chunk files has a lot of metadata. Without a special device, this metadata uses space on the normal vdevs.

zpool list and zfs list show different numbers

The zpoolprops man page states that the space properties of zpool list report physical space. On RAIDZ, this space includes parity. zfs list shows the space that datasets can use, after parity and the reserve. For capacity planning, use the AVAIL column of zfs list.

bash
zpool list -v <pool>
zfs list -o space <pool>
zfs get recordsize,compression <pool>/<dataset>
Compare pool space and dataset space

What this means for a PBS datastore

A Proxmox Backup Server datastore is a directory on a file system, not a ZVOL. PBS stores the backup data as chunk files under .chunks/. For VM backups, the PBS technical overview states that PBS splits the disk image into chunks of the same length, typically 4 MiB. File backups use chunks of dynamic size.

A file that is larger than the recordsize is stored in full records. The default recordsize is 128K, and chunk files are often much larger. So most chunk data uses large blocks, and the 128K example above applies: the usable space comes close to the (N-P) rule. The 8K ZVOL example from the Proxmox VE documentation applies to VM disks on RAIDZ, not to a datastore.

The pool size is not the amount of backups that fit. Proxmox Backup Server deduplicates chunks, so ten backups of a VM with few changes need little more space than one. Inside the PBS Chunk Store explains how deduplication works.

Mirror or RAIDZ for a datastore

The choice is a trade-off between space and IOPS. The Proxmox VE documentation states that a RAIDZ vdev of any level has about the IOPS of a single disk, with a lot of bandwidth. A mirror writes like one disk and reads like all its disks. More vdevs in a pool give more IOPS.

The OpenZFS tuning guide gives the same rule for the RAIDZ width: use fewer disks per vdev for more IOPS, and more disks per vdev for more usable space.

A datastore has random read load. Garbage collection and verify jobs touch many chunk files. The PBS system requirements recommend fast local storage with high IOPS, and enterprise SSDs for the best results. For HDDs, they recommend a metadata cache, for example a ZFS special device mirror. PBS Performance Tuning covers the other settings, and the PBS storage backend comparison compares ZFS with a directory and LVM-thin.

The special device and capacity

A special device stores the metadata of the pool, the deduplication tables of ZFS, and optionally small file blocks. It does not add space for chunk data. Use these rules from the Proxmox VE and OpenZFS documentation:

  • Give the special device the same redundancy as the pool. If the special device fails, the pool fails.
  • You cannot undo the addition of a special device to a pool. Plan it before you add it.
  • If the special device becomes full, ZFS writes new metadata to the normal vdevs.
  • The special_small_blocks property moves blocks smaller than its value to the special device. If you set it to the recordsize or higher, all data goes to the special device.
bash
zpool add <pool> special mirror <device1> <device2>
Add a mirrored special device to an existing pool
This change is permanent

Check the device names twice before you run zpool add. A special device without redundancy is a single point of failure for the whole pool.

Plan for free space

The OpenZFS tuning guide recommends that you keep more than 10% of the pool free. Below about 4% free space in a metaslab, ZFS changes its allocation method, and this reduces IOPS.

Free space on a datastore also does not come back at once. When a prune job removes a backup snapshot, the chunks stay on the disk. Only garbage collection deletes chunks that no backup uses. Proxmox Backup Server Pruning and Garbage Collection explains the steps and the timing.

A rough plan for the six-disk RAIDZ2 example:

  1. Parity rule: 16 TB, which is about 14.55 TiB.
  2. Less the reserve of 128 GiB (the maximum, because the pool is large): about 14.4 TiB.
  3. Less 10% free space: about 13 TiB for backup data and metadata.

This is an estimate. Metadata, compression and the real block sizes change the result. Check the AVAIL column of zfs list after the first backups.

Growing a RAIDZ vdev later

The OpenZFS documentation describes RAIDZ expansion: you can attach a new disk to an existing RAIDZ vdev with zpool attach. The parity level stays the same. Blocks that ZFS wrote before the expansion keep their old ratio of data to parity. Only new blocks use the wider ratio. So the pool after expansion has less space than a new pool with the same disks.

Plan the layout before the first backup

You cannot change the RAIDZ level of a vdev, and the ashift of a vdev is fixed when you create it. Choose both before the datastore gets data.

Wrapping Up

Start with the parity rule: (N-P) × disk size for RAIDZ, and 50% for 2-way mirrors. Then subtract the unit difference, the ZFS reserve, and 10% free space. Chunk files are often large, so a datastore on RAIDZ comes close to the parity rule. A special device helps HDD pools with metadata, but it needs the same redundancy as the pool.

Connect your datastore

Already a customer? The datastore docs show how to add your remote-backups.com datastore to Proxmox Backup Server.

Read the datastore docs

About (N-2) times the disk size, for N disks. Six 4 TB disks in RAIDZ2 give about 16 TB, which ZFS shows as about 14.55 TiB. The ZFS reserve, metadata and small blocks reduce this further.

On RAIDZ, zpool list shows physical space, which includes parity. zfs list shows the space that datasets can use, after parity and the ZFS reserve.

The Proxmox VE documentation states that two 2-way mirrors give the same usable space as a 4-disk RAIDZ2, with better performance. The difference: RAIDZ2 survives any two failed disks. Two mirrors survive two failed disks only when the disks are in different mirrors.

No. It stores metadata and optionally small blocks. Chunk data stays on the normal vdevs. If the special device is full, new metadata goes to the normal vdevs.

The OpenZFS tuning guide recommends that you keep more than 10% of the pool free. ZFS also keeps a reserve (about 3.2% of the pool, at most 128 GiB), and most writes fail when only this reserve is left.
Bennet Gallein
Bennet Gallein

remote-backups.com operator

Infrastructure enthusiast and founder of remote-backups.com. I build and operate reliable backup infrastructure powered by Proxmox Backup Server, so you can focus on what matters most: your data staying safe.