Enable Linux Filesystem Quotas Safely with quotaon
quotaon is the switch that turns disk quota enforcement on for a filesystem, and picking the wrong mount or quota type flips it for the wrong users. By the end of this guide you can check quota state, enable quotas on a chosen filesystem, verify the result, and undo the change with quotaoff. Allow about ten minutes if the quota files or mount options already exist.
The route
Jump straight to the step you need, or tick off Done means at the end.
This is an administrative operation: use a root shell or prefix commands with sudo.
Before you change anything
This guide describes quota utilities version 4.06, installed from the Debian/Ubuntu quota package version 4.06-1build6 on the reference system. Your output can differ on a different package or kernel. You need the filesystem mount point, permission to administer it, and a clear choice between user, group and project quotas.
Do not start with quotaon -a unless you have reviewed /etc/fstab first. That form acts on every automatically mounted, non-NFS filesystem listed there with quotas configured, so a mistake in the configuration can hit several filesystems at once.
Checkpoint
You know the exact mount point, such as /srv or /, and whether the target is XFS.
1. Identify the filesystem and quota type
Run these read-only checks as your normal user, replacing the example path with the filesystem you intend to manage:
$ findmnt -no TARGET,FSTYPE,OPTIONS /srv
$ grep -E '^[^#].*[[:space:]]quota|usrquota|grpquota|prjquota' /etc/fstab
The first command shows the filesystem type and mount options. The second is only a quick search, so inspect the matching /etc/fstab line directly. On non-XFS filesystems, user and group quota data normally lives at the filesystem root as aquota.user or aquota.group for version 2, or quota.user or quota.group for version 1.
Quota type matters: -u selects user quotas, -g selects group quotas, -P selects project quotas. User quotas are the default, but state that choice explicitly in scripts and runbooks anyway.
2. Inspect current state without changing it
Use -p to print state. It reports each supported quota type and turns nothing on or off:
$ sudo quotaon -p /srv
user quota on /srv (/dev/DEVICE) is off
group quota on /srv (/dev/DEVICE) is off
project quota on /srv (/dev/DEVICE) is off
The device name and the set of lines depend on the filesystem and kernel. Expect a non-zero exit status when one or more requested types are off, so read the output rather than treating the status alone as failure. Add -u, -g or -P to inspect one type at a time.
Checkpoint
You have recorded the current state and confirmed the mount point is the one you intend to modify.
3. Enable quotas on a non-XFS filesystem
Make sure the required quota file exists at the filesystem root and that the quota database has already been initialised by the rest of your quota-management workflow. This command only announces that quotas should be enabled, it does not create sensible limits for users or groups.
For user quotas on one filesystem:
$ sudo quotaon -v -u /srv
/dev/DEVICE [/srv]: user quotas turned on
The exact verbose wording varies with filesystem and package. Use -g for group quotas or -P for project quotas, and keep the filesystem argument explicit when testing one mount. -v makes the affected filesystem visible in logs, which matters when the command runs from automation.
To enable the configured set from /etc/fstab, use this only after reviewing that file:
$ sudo quotaon -av
/dev/DEVICE [/srv]: user quotas turned on
-a covers automatically mounted non-NFS filesystems with quotas in /etc/fstab. It is commonly used at boot, but it is not a substitute for checking the configuration first.
4. Verify the result
Repeat the state check, selecting the same type you enabled:
$ sudo quotaon -p -u /srv
user quota on /srv (/dev/DEVICE) is on
For a fuller operational check, use repquota if it is installed and permitted in your environment:
$ sudo repquota -v /srv
An enabled quota database is not the same as configured limits. quotaon changes whether the kernel does quota accounting and enforcement; setting user, group or project limits is a separate task. Keep the original quota files and configuration until you have checked reporting and the application workload.
Checkpoint
The selected quota type reports on, and reporting shows the expected filesystem.
5. Handle XFS differently
XFS stores quota information internally rather than in visible aquota.* files. Quota accounting has to be enabled at mount time, through mount options or the matching /etc/fstab entry. quotaon cannot switch on XFS accounting for an already-mounted filesystem.
Once XFS accounting is already enabled, quotaon can turn on limit enforcement while the filesystem stays mounted:
$ sudo quotaon -v /srv
$ sudo quotaon -p /srv
For an XFS root filesystem, the quota mount options must reach the kernel through the boot-time rootflags option. Treat that as a separate, higher-risk maintenance task with a recovery path arranged before you reboot.
6. Turn quotas off or undo enforcement
Disabling quotas changes enforcement for the selected filesystem and can let usage exceed limits, so warn affected users or services first. To disable user quotas on one mount:
$ sudo quotaoff -v -u /srv
$ sudo quotaon -p -u /srv
On XFS, the ordinary quotaoff action disables limit enforcement but leaves accounting in place; re-enable enforcement with quotaon -v /srv. Do not use the XFS -x delete action as routine cleanup, it frees internally maintained quota information and is only valid after quotas are off. -x account disables XFS accounting; re-enabling accounting needs mount options, not quota tools.
quotaon -f is an alternative spelling that makes quotaon behave like quotaoff. Prefer quotaoff in new commands so intent is visible at a glance.
Common failure traps
- Missing quota files: on a non-XFS filesystem, check the filesystem root for the correctly named user or group file. A plausibly named file in another directory does not count.
- Wrong quota type: the default is user quotas. Add
-gor-Pwhen managing groups or projects, and use the same choice for verification. - Expecting
-ato mean every mount: it only follows the relevant/etc/fstaband automatic-mount rules, and excludes NFS filesystems. - Using quotaon to start XFS accounting: set the XFS mount option and remount or reboot through your maintenance procedure.
quotaononly changes enforcement once accounting already exists. - Reading only the exit status of
-p: check the printed state for each quota type. An off type can produce a non-zero status even when the state report itself worked fine.
Done means
- The target mount point and filesystem type were checked before any state change.
- The intended quota type was named explicitly with
-u,-gor-P. quotaon -preports the intended type ason.- Non-XFS quota files or XFS mount-time accounting were handled with the right model.
- You know the matching
quotaoffcommand and did not delete quota data as part of routine rollback.