Linux Command Reference ยท Disks and Filesystems
Linux quota command and disk quotas
Reference for Linux disk quotas: soft and hard limits, grace periods, quota, edquota, setquota and repquota, enabling usrquota in fstab, and XFS project quotas.
Disk quotas limit how much space (blocks) and how many files (inodes) a user, a group or a project may consume on a filesystem. They protect shared servers from one runaway account that fills the disk for everybody.
Each limit has two levels. The soft limit can be exceeded temporarily, for a period called the grace period. The hard limit can never be exceeded: writes fail with "Disk quota exceeded". Once the grace period expires, the soft limit acts as a hard limit until usage drops below it.
quota -s sudo repquota -s /home
Try it
Quotas need root, a filesystem mounted with quota options and the quota tools, none of which the sandbox has. The examples are read-only simulations of the tools' arithmetic and output, so you can practice reading reports.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.
Syntax
quota [-s] [-u USER | -g GROUP] edquota [-u USER | -g GROUP | -t] setquota -u USER BSOFT BHARD ISOFT IHARD FILESYSTEM repquota [-s] [-a | FILESYSTEM] quotacheck -cug FILESYSTEM quotaon -v FILESYSTEM quotaoff FILESYSTEM
| Command | Description |
|---|---|
quota |
Show your own usage and limits; root can pass -u user or -g group. -s prints human readable sizes. |
edquota -u USER |
Open an editor with the user's limits; -t edits the grace periods. |
setquota |
Set limits from the command line, good for scripts. |
repquota -a |
Report usage for all quota-enabled filesystems. |
quotacheck |
Scan a filesystem and build or repair the quota files (filesystem should be quiet or read-only). |
quotaon / quotaoff |
Switch enforcement on or off. |
Fields in a limit: blocks soft, blocks hard, inodes soft, inodes hard. A value of 0 means no limit.
Returns: 0 on success; non-zero for errors such as "Cannot find mountpoint" or when quotas are not enabled for the filesystem.
Usage notes
- Enable them on the filesystem first. For ext4, add
usrquotaand/orgrpquotato the mount options in/etc/fstaband remount; on modern ext4 you can also enable the hidden quota feature withtune2fs -O quota. Create the quota databases withquotacheck, thenquotaon. - XFS is different. XFS manages quotas internally. Mount with
uquota,gquotaorpquota(they must be set at mount time, not remounted) and administer withxfs_quota -x -c 'limit bsoft=5g bhard=6g alice' /home. - Project quotas limit a directory tree regardless of owner, which suits containers and web sites. They are available on XFS and on ext4 with the project feature.
- Quota counts what a user owns, not where files are. Files owned by
aliceon the filesystem count even if they sit in a shared directory. - Root and sudo-created files are charged to their owner;
chownmoves the charge. - Tell users. A full quota shows up as "Disk quota exceeded" in applications that otherwise seem fine. Mail, build and database jobs often fail confusingly.
- Inode limits stop users from creating millions of tiny files, which can exhaust a filesystem long before the block space is full.
- Reading numbers: the reports use 1 KiB blocks unless you add
-s, which scales to human units. - Check usage without quotas using
duanddf.
Related
du,df,mount, fstab and mount options- Lessons: Disk usage, Disks and logs