Setting Quotas on ZFS File Systems
Quotas on ZFS file systems can be set and displayed by using the zfs
set
and zfs get
commands. In the following example,
a quota of 10GB is set on tank/home/sueb
:
$ zfs set quota=10G tank/home/sueb $ zfs get quota tank/home/sueb NAME PROPERTY VALUE SOURCE tank/home/sueb quota 10G local
Quotas also affect the output of the zfs list
and df
commands. For example:
$ zfs list -r tank/home NAME USED AVAIL REFER MOUNTPOINT tank/home 1.45M 66.9G 36K /tank/home tank/home/glori 547K 66.9G 547K /tank/home/glori tank/home/sueb 322K 10.0G 291K /tank/home/sueb tank/home/sueb/ws 31K 10.0G 31K /tank/home/sueb/ws tank/home/mork 31K 66.9G 31K /tank/home/mork $ df -h /tank/home/sueb Filesystem Size Used Avail Use% Mounted on tank/home/sueb 10G 306K 10G 1% /tank/home/sueb
Note that although tank/home
has 66.9GB of disk space
available, tank/home/sueb
and
tank/home/sueb/ws
each have only 10GB of disk space
available, due to the quota on tank/home/sueb
.
You can set a refquota
on a file system that limits the amount of disk space that the file system can consume. This limit does not include disk space that is consumed by descendents. For example, studentA's 10GB quota is not impacted by space that is consumed by snapshots.
$ zfs set refquota=10g students/studentA $ zfs list -t all -r students NAME USED AVAIL REFER MOUNTPOINT students 150M 66.8G 32K /students students/studentA 150M 9.85G 150M /students/studentA students/studentA@yesterday 0 - 150M - $ zfs snapshot students/studentA@today $ zfs list -t all -r students students 150M 66.8G 32K /students students/studentA 150M 9.90G 100M /students/studentA students/studentA@yesterday 50.0M - 150M - students/studentA@today 0 - 100M -
For additional convenience, you can set another quota on a file system to help manage the disk space that is consumed by snapshots. For example:
$ zfs set quota=20g students/studentA $ zfs list -t all -r students NAME USED AVAIL REFER MOUNTPOINT students 150M 66.8G 32K /students students/studentA 150M 9.90G 100M /students/studentA students/studentA@yesterday 50.0M - 150M - students/studentA@today 0 - 100M -
In this scenario, studentA
might reach the refquota
(10GB) hard limit, but studentA
can remove files to recover, even if snapshots exist.
In the preceding example, the smaller of the two quotas (10GB as compared to 20GB) is displayed in the zfs list
output. To view the value of both quotas, use the zfs get
command. For example:
$ zfs get refquota,quota students/studentA
NAME PROPERTY VALUE SOURCE
students/studentA refquota 10G local
students/studentA quota 20G local
Enforcement of a file system quota might be delayed by several seconds. This delay means that a user might exceed the file system quota before the system notices that the file system is over quota and refuses additional writes with the EDQUOT
error message.