ZFS quota
Posted on April 19, 2017 • 2 minutes • 254 words • Suggest Changes
ZFS is brimming with valuable features and functions, and recently, I had the opportunity to explore setting quotas. With just a handful of commands, you can effectively restrict the amount of storage that a specific pool can consume.
First let’s check if there is no quota set :
zfs get quota
This would result in something like :
# zfs get quota NAME PROPERTY VALUE SOURCE pool quota none default pool/dataset quota none default [...]
As you may have noticed, there are currently no quotas set. Now, let’s proceed to add a quota to the desired resource :
zfs set quota=5TB pool/dataset
This would add a 5TB limit to pool/dataset.
The format :
zfs set quota=$size $pool
To find the exact size of a volume and make the current size the limit :
zfs get -Hp used pool/volume pool/volume used 19321891149600 -
Set the limit to exactly the size of pool/volume (making it “almost” readonly)
zfs set quota=19321891149600 pool/volume
It’s ofcourse also possible to just set the readonly flag on :
zfs set readonly=on pool/volume
Let’s check again :
zfs get -r quota pool/data NAME PROPERTY VALUE SOURCE pool/data quota 5T local pool/data@autosnap_2017-04-01_00:00:02_daily quota - -
Simple enough; now some practical warnings :
- full is full; you can’t remove, edit or overwrite data once its 100% full. Even tricks like “echo > big_file” won’t work. You need to either increase or drop the quota before its possible
- You can’t decrease a quota … once its allowed 5TB only destroying it will release the limit.