Skip to content

Disk_quotas

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 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

  • 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