Skip to content

Disk Quotas and Limits

Disk quotas allow administrators to limit disk space and file count for users and groups. This chapter covers quota setup, management, monitoring, and best practices for Linux systems in production environments.


Disk quotas prevent resource exhaustion - a single user can fill filesystem and cause outage for everyone. Essential for multi-tenant systems, shared environments, and preventing denial-of-service.

┌─────────────────────────────────────────────────────────────────────────────┐
│ DISK QUOTAS IN DEVOPS │
├─────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ OPERATIONAL IMPORTANCE │ │
│ │ │ │
│ │ • Multi-tenant systems - Prevent one user affecting others │ │
│ │ • Shared storage - Fair resource allocation │ │
│ │ • Cost control - Limit storage consumption │ │
│ │ • Incident prevention - Stop disk exhaustion before it happens │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ COMMON SCENARIOS │ │
│ │ │ │
│ │ Development Teams: │ │
│ │ • Limit /home to prevent personal data filling disk │ │
│ │ • Limit /tmp for temporary files │ │
│ │ • Limit /var for logs │ │
│ │ │ │
│ │ Production: │ │
│ │ • Container hosts - Per-container limits │ │
│ │ • CI/CD servers - Build artifact limits │ │
│ │ • File servers - Per-user limits │ │
│ │ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────────┘

┌─────────────────────────────────────────────────────────────────────────┐
│ DISK QUOTA TYPES │
├─────────────────────────────────────────────────────────────────────────┤
│ │
│ User/Group Quotas: │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ User quotas: Limit disk space/files per user │ │
│ │ Group quotas: Limit disk space/files per group │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
│ Block/Inode Limits: │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Block limits: Disk space in KB/MB (actual storage used) │ │
│ │ Inode limits: Number of files (prevents tiny file attack) │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
│ Limit Types: │
│ ┌─────────────────────────────────────────────────────────────────┐ │
│ │ Soft limit: Warning threshold, can exceed during grace period │ │
│ │ Hard limit: Absolute maximum, cannot exceed │ │
│ │ Grace period: Time allowed to exceed soft limit │ │
│ └─────────────────────────────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────────┘

Terminal window
# Install quota tools
# Debian/Ubuntu
sudo apt install quota
# RHEL/CentOS
sudo yum install quota
# Arch Linux
sudo pacman -S quota-tools
Terminal window
# /etc/fstab - add usrquota,grpquota
# /dev/sda1 / ext4 defaults,usrquota,grpquota 0 1
# For XFS filesystem (use uquota,gquota instead)
/dev/sda1 / xfs defaults,uquota,gquota 0 0
# Remount filesystem
sudo mount -o remount /
# Verify
mount | grep quotas
Terminal window
# Create quota files
sudo quotacheck -cugm /
# Options:
# -c: create new quota files
# -u: user quotas
# -g: group quotas
# -m: don't remount read-only
# Verify created files
ls -la /aquota.*
# -rw------- 1 root root 7168 /aquota.user
# -rw------- 1 root root 6144 /aquota.group
Terminal window
# Enable quotas
sudo quotaon /
sudo quotaon -av
# Disable quotas
sudo quotaoff /
# Enable for specific filesystem
sudo quotaon -uv /home
sudo quotaon -gv /home

Terminal window
# Edit user quota interactively
sudo edquota -u username
# Example output:
# Disk quotas for user john (uid 1000):
# Filesystem blocks soft hard inodes soft hard
# /dev/sda1 1000 5000 10000 50 100 200
# Set limits in GB
sudo edquota -u john
# blocks: current usage in KB
# soft: 5GB = 5242880 KB
# hard: 10GB = 10485760 KB
# Set inode limits
# soft: 100 files
# hard: 200 files
Terminal window
# Edit group quota
sudo edquota -g developers
# Set limits in GB
sudo edquota -g developers
# soft: 50GB
# hard: 100GB
Terminal window
# Copy quota settings from one user to another
sudo edquota -p user1 user2 user3
# Useful for setting up multiple users with same limits
Terminal window
# Check user quota
quota -u username
quota -u john
# Check group quota
quota -g groupname
# Generate quota report
repquota -a
repquota -aug
# Check quota without being root
sudo -u username quota -u username

Terminal window
# Set grace period for soft limits
sudo edquota -t
# Example:
# Block grace period: 7 days
# Inode grace period: 7 days
# During grace period, users can exceed soft limit
# After grace period, soft limit becomes enforced

Terminal window
# XFS uses different quota commands
# Enable in /etc/fstab
# /dev/sda1 / xfs defaults,uquota,gquota 0 0
# Report XFS quotas
xfs_quota -x -c 'report -h' /
# Set limits
xfs_quota -x -c 'limit bsoft=5g bhard=10g john' /
# Set inode limits
xfs_quota -x -c 'limit isoft=100 ihard=200 john' /
# Real-time monitoring
xfs_quota -x -c 'state' /

Terminal window
# Check quota usage
repquota -a
# Find users approaching limits
sudo repquota -a | grep -E "^[+-]"
# Quota violations in logs
# Check /var/log/messages for quota warnings
# Common issues:
# - "Disk quota exceeded" errors
# - Cannot create new files
# - Check grace period with: quota -u username -v

┌─────────────────────────────────────────────────────────────────────────┐
│ DISK QUOTA INTERVIEW QUESTIONS │
├─────────────────────────────────────────────────────────────────────────┤
Q1: What is the difference between soft and hard limits? │
A1: │
- Soft limit: Warning threshold, can be exceeded during grace period │
- Hard limit: Absolute maximum, cannot be exceeded │
- After grace period expires, soft limit becomes enforced │
─────────────────────────────────────────────────────────────────────────┤
Q2: How do you enable disk quotas on Linux? │
A2: │
1. Add usrquota,grpquota to /etc/fstab │
2. Remount filesystem: mount -o remount / │
3. Create quota files: quotacheck -cugm / │
4. Enable quotas: quotaon / │
─────────────────────────────────────────────────────────────────────────┤
Q3: What are inode quotas and why are they useful? │
A3: │
- Limit number of files a user/group can create │
- Prevents "tiny file attack" (many 0-byte files) │
- Useful for preventing directory exhaustion │
- Set separately from block (space) quotas │
─────────────────────────────────────────────────────────────────────────┤
Q4: How do you set up quotas for multiple users quickly? │
A4: │
- Set quota for one user as template │
- Use edquota -p template_user user1 user2 user3 │
- Or use script with setquota command │
─────────────────────────────────────────────────────────────────────────┤
Q5: What happens when a user exceeds their hard limit? │
A5: │
- Cannot create new files │
- Cannot extend existing files │
- Gets "Disk quota exceeded" error │
- Must delete files or administrator must increase limit │
─────────────────────────────────────────────────────────────────────────┤
Q6: How do XFS quotas differ from traditional quotas? │
A6: │
- XFS uses uquota,gquota mount options │
- Different commands: xfs_quota │
- Can be managed in real-time without quotacheck │
- More scalable for large systems │
─────────────────────────────────────────────────────────────────────────┤
Q7: How do you check which users are using the most disk space? │
A7: │
repquota -a or repquota -aug │
Sort by blocks column │
─────────────────────────────────────────────────────────────────────────┤
Q8: What is quota grace period? │
A8: │
- Time allowed to exceed soft limit before enforcement │
- Set with edquota -t command │
- Applies to both block and inode quotas │
- Default is usually 7 days │
└─────────────────────────────────────────────────────────────────────────┘

Terminal window
# Setup
apt install quota
# Add usrquota,grpquota to /etc/fstab
mount -o remount /
quotacheck -cugm /
quotaon /
# Management
edquota -u username # Edit user quota
edquota -g groupname # Edit group quota
edquota -p user1 user2 # Copy quota
quota -u username # Check quota
repquota -a # Full report
quotaon /quotaoff / # Enable/disable

WRONG:

Terminal window
# Set soft limit but no grace period
edquota -u user
# Soft limit: 10GB, Hard limit: 20GB
# No grace period - soft limit acts as hard limit immediately

CORRECT:

Terminal window
# Set grace period
setquota -t 86400 # 1 day for blocks
setquota -t 86400 # 1 day for inodes
# Or via edquota -t

Why: Grace period allows users time to clean up before hard limit enforced.


WRONG:

Terminal window
# Only block quota - inode exhaustion still possible
# Many small files can fill inodes even with space remaining

CORRECT:

Terminal window
# Set both block and inode limits
edquota -u user
Disk quotas for user user (uid 1000):
Filesystem blocks soft hard inodes soft hard
/dev/sda1 1000000 10485760 20971520 100000 500000 1000000

Why: Inode exhaustion prevents new file creation even with free space.


WRONG:

Terminal window
# Quota works initially but stops after reboot
# Forgot to add quota to fstab or startup

CORRECT:

Terminal window
# In /etc/fstab
/dev/sda1 /home ext4 defaults,usrquota,grpquota 0 2
# Add to startup
systemctl enable quotaon.service
# OR add to /etc/rc.local
/usr/sbin/quotaon -aug

Why: Quotas must be explicitly enabled at each boot.


WRONG:

Terminal window
# Limits too restrictive
# Hard limit: 1GB for /home
# Users can't work effectively

CORRECT:

Terminal window
# Research actual usage patterns
repquota -a
# Set soft limit at ~80% of expected usage
# Set hard limit at ~120% of expected usage
# Allow for growth

Why: Too low limits prevent legitimate work; too high defeats purpose.


WRONG:

Terminal window
# Only user quotas
# Team can collude to exceed total limit
# Shared project space not controlled

CORRECT:

Terminal window
# Enable group quotas too
mount -o grpquota /dev/sda1 /home
# Set group limits
edquota -g developers

Why: Group quotas prevent teams from collectively exceeding limits.


  • Types: User, Group, Block (space), Inode (files)
  • Limits: Soft (warning), Hard (maximum)
  • Tools: edquota, quota, repquota, quotacheck, xfs_quota
  • Setup: fstab → remount → quotacheck → quotaon

Chapter 16: Process Management


Last Updated: February 2026