[TUTORIAL] Protect a PBS datastore on ZFS, so that it does not become completely full

mariol

Proxmox Staff Member
Staff member
Jul 2, 2024
242
67
33
Wien
proxmox.com
Sometimes it can happen, a ZFS pool become 100% full. Since ZFS is a COW (Copy-on-Write FS), it is very difficult to remove data from it because at least enough space must be free to write a timestamp.

To prevent this from happening, you can create a dataset and reserve some storage space (~20 GB). This allows you simply to delete the dataset in the worst case.

Code:
zfs create  <poolname>/reserve
zfs set refreservation=20G reservation=20G  <poolname>/reserve

Delete the dataset in the worst case:
Code:
zfs destroy  <poolname>/reserve
 
  • Like
Reactions: MarkusKo
I use zfs create -o reservation=100G pool/.reserved-space and also monitor the space usage.
If you have an emergency, as in the space is full, and forgot to do that before then temporarily altering spa_slop_shift might help.
For example
Bash:
# Shows current value. Default is 5
cat /sys/module/zfs/parameters/spa_slop_shift

echo 6 > /sys/module/zfs/parameters/spa_slop_shift
Increase the value if needed. Make sure to revert this to the default/previous value when done.

Here's an example of the reserved percentage you get with different values
Code:
1:  50.000
2:  25.000
3:  12.500
4:  6.250
5:  3.125
6:  1.562
7:  0.781
8:  0.390
9:  0.195
10: 0.097
11: 0.048
12: 0.024
13: 0.012
14: 0.006
15: 0.003
16: 0.001
 
Last edited: