· Kalpa Madhushan · system administration · 3 min read
Setting User-Level Disk Quotas in Linux: Complete Guide
Learn how to implement and manage user-level disk quotas in Linux systems, including quota setup, configuration, enforcement, and monitoring techniques for system administrators.

Setting User-Level Disk Quotas in Linux
This article will guide you through user-level disk quotas in Linux from scratch, explaining each command, its flags, arguments, and other uses.
1. Understanding Disk Quotas
Disk quotas limit the amount of disk space and number of files (inodes) a user or group can use on a filesystem.
- Block quota: limits storage size (e.g., 50 MB).
- Inode quota: limits number of files (e.g., 100 files).
Quotas help prevent denial-of-service attacks where a user creates too many files or fills up disk space.
2. Checking Filesystem Type
df -Th /home
df
→ shows disk usage.-T
→ shows filesystem type.-h
→ human-readable sizes.
Other uses: check other mount points, verify free space, or identify filesystem type before performing FS-specific operations.
3. Editing /etc/fstab
for Quotas
Example line for ext4 root filesystem:
/dev/disk/by-id/dm-uuid-xyz / ext4 defaults,usrquota,grpquota 0 1
usrquota
→ enable per-user quotas.grpquota
→ enable per-group quotas.
Other uses: add mount options like noatime
, ro
, noexec
for performance or security.
4. Remounting Filesystem
sudo mount -o remount /
mount | grep " / "
mount -o remount /
→ applies new options without rebooting.mount | grep " / "
→ checks active mount options.
Other uses:
mount -o remount,ro /
→ switch root FS to read-only.mount -o remount,noatime /
→ disable file access time updates.mount | grep /home
→ check mount status of/home
.
5. Installing Quota Tools
If quotacheck
is missing:
sudo apt install quota # Ubuntu/Debian
sudo dnf install quota # RHEL/Fedora
- Provides
quotacheck
,quotaon
,edquota
,repquota
, andquota
.
6. Creating Quota Database Files
sudo quotacheck -cum / # user quotas
sudo quotacheck -cgum / # group quotas
-c
→ create quota files.-u
→ check user quotas.-g
→ check group quotas.-m
→ ignore read-only remount.-v
→ verbose.
Other uses: recalculate usage after large deletions or FS repairs.
7. Enabling Quotas
sudo quotaon /
- Turns on quota enforcement on the filesystem.
quotaon -v /
→ verbose.
Why errors appear: root FS busy, but repquota
will still work.
8. Creating a New User for Testing
sudo adduser testuser
id testuser
- Creates
/home/testuser
, sets password, adds to/etc/passwd
. id
shows UID, GID, and groups.
9. Setting Quotas for the User
Interactive method:
sudo edquota -u testuser
Columns:
- blocks: current KB usage.
- soft/hard blocks: warning and max size.
- inodes: number of files.
- soft/hard inodes: warning and max file count.
Example for testing:
/dev/mapper/ubuntu--vg-ubuntu--lv 16 20 25 4 5 6
- Soft/hard limits are very low for easy testing.
10. Testing Quotas
Inode test:
su - testuser
cd ~
touch file1 file2 file3 file4 file5 file6
- Soft inode limit warning appears at file 5.
- Hard inode limit error at file 6.
Space test:
dd if=/dev/zero of=file1 bs=10K count=1
dd if=/dev/zero of=file2 bs=10K count=1
- Hard block limit triggers
Disk quota exceeded
when exceeded. quota -u testuser
shows current usage vs limits.
11. Verifying Quotas
repquota / # list all quotas and usage
quota -u testuser # show specific user usage
- Confirms limits are applied and usage is tracked.
- Even if
quotaon
gave busy errors, this confirms enforcement.
✅ Summary
We have:
- Checked filesystem type.
- Edited
/etc/fstab
and remounted. - Installed quota tools.
- Created quota database files.
- Enabled quota enforcement.
- Created a test user and set quotas.
- Tested both inode and space limits.
- Verified everything with
repquota
andquota
.
This covers learning quotas hands-on while also teaching each command, its arguments, flags, and other useful use cases.