Disk Quotas — Controlling Storage Usage in Linux¶
Disk Quotas allow Linux administrators to control and limit the amount of disk space and the number of files (inodes) that users or groups can consume on a filesystem. Quotas help prevent a single user or application from exhausting available storage, ensuring fair resource allocation and maintaining system stability. Disk quotas are widely used on multi-user systems, universities, enterprise servers, shared hosting platforms, and cloud environments.
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand disk quotas
- Configure user and group quotas
- Learn soft and hard limits
- Enable quota support
- Monitor quota usage
- Manage quota violations
- Apply quota best practices in production
Prerequisites¶
Complete:
- Module 1 – Linux Fundamentals
- Module 2 – Linux Command Line Essentials
- Module 3 – Text Processing
- Module 4 – File Management
- Module 5 – Users and Groups
- Module 6 – Process Management
- Module 7 – Package Management
- Module 8 – Networking
- Module 9 Lessons 1–7
Why Learn Disk Quotas?¶
Imagine:
- One user fills an entire shared server with log files.
- A developer accidentally uploads hundreds of gigabytes of data.
- A web hosting customer consumes all available storage.
- A backup application generates excessive files.
Without quotas:
With quotas:
What are Disk Quotas?¶
Disk quotas allow administrators to limit:
- Disk space usage
- Number of files (inodes)
Quotas can be applied to:
- Individual users
- Groups
Why Use Quotas?¶
Quotas help:
- Prevent storage exhaustion
- Ensure fair resource allocation
- Protect shared servers
- Improve storage management
- Reduce operational risks
Types of Quotas¶
Linux supports:
- User Quotas
- Group Quotas
Example:
Soft Limit¶
A soft limit is a warning threshold.
Example:
The user can temporarily exceed the limit during the configured grace period.
Hard Limit¶
A hard limit is an absolute maximum.
Example:
Once reached:
Grace Period¶
The grace period allows users to temporarily exceed the soft limit.
Example:
After the grace period expires, the soft limit is enforced as if it were a hard limit until usage is reduced.
Quota Workflow¶
User Writes File
↓
Quota Check
↓
Below Limit
↓
File Created
OR
Hard Limit Reached
↓
Operation Denied
Enable Quotas¶
Edit:
Example:
Options:
usrquotagrpquota
Remount the Filesystem¶
Create Quota Database¶
Options:
| Option | Meaning |
|---|---|
-c | Create quota files |
-u | User quotas |
-g | Group quotas |
Enable Quotas¶
Verify:
Configure User Quota¶
Example:
Configure Group Quota¶
Copy Quotas¶
Copy quota settings from one user to another.
View User Quota¶
View Current User Quota¶
Display Quota Report¶
Shows:
- Users
- Groups
- Space usage
- Soft limits
- Hard limits
Disable Quotas¶
Common Commands¶
Create quota database.
Enable quotas.
Edit quotas.
View quotas.
Quota report.
Real Production Examples¶
Set quota for a developer.
View quota usage.
Generate report.
Production Perspective¶
Disk quotas are commonly used for:
- Multi-user Linux servers
- University computer labs
- Shared hosting platforms
- Development servers
- Cloud virtual machines
- Enterprise storage
- Home directories
- Shared file servers
Quotas help prevent individual users from consuming excessive storage resources.
Hands-on Lab¶
Task 1¶
View mounted filesystems.
Task 2¶
Enable quota support in /etc/fstab.
Task 3¶
Remount the filesystem.
Task 4¶
Create quota files.
Task 5¶
Enable quotas.
Task 6¶
Configure a user quota.
Task 7¶
View quota usage.
Task 8¶
Generate a quota report.
Command Deep Dive¶
| Command | Purpose | Production Example |
|---|---|---|
quotacheck | Create quota database | Initial configuration |
quotaon | Enable quotas | Production servers |
quotaoff | Disable quotas | Maintenance |
edquota | Configure quotas | User management |
quota | View quota usage | User monitoring |
repquota | Generate quota report | Capacity planning |
Soft Limit vs Hard Limit¶
| Feature | Soft Limit | Hard Limit |
|---|---|---|
| Warning Threshold | Yes | No |
| Temporary Exceeding Allowed | Yes | No |
| Grace Period | Yes | No |
| Absolute Maximum | No | Yes |
Common Quota Errors¶
| Error | Possible Cause |
|---|---|
Quota not enabled | quotaon not executed |
No quota support | Missing usrquota/grpquota mount options |
Permission denied | Insufficient privileges |
Quota exceeded | Hard limit reached |
Production Troubleshooting Scenario¶
Scenario
A shared development server reports:
Investigation:
The filesystem is full.
Generate a quota report.
The report shows one developer consuming most of the available storage.
The administrator sets appropriate quotas.
Future storage growth is controlled, preventing one user from impacting others.
Best Practices¶
- Enable quotas on shared filesystems.
- Configure both soft and hard limits.
- Monitor quota reports regularly.
- Use reasonable grace periods.
- Review quotas periodically as storage needs change.
- Educate users about storage limits.
Common Mistakes¶
❌ Forgetting to enable quota support in /etc/fstab.
✅ Remember to to enable quota support in /etc/fstab.
❌ Creating quota files but not enabling quotas.
✅ Avoid this mistake: creating quota files but not enabling quotas.
❌ Setting hard limits too low for business needs.
✅ Avoid this mistake: setting hard limits too low for business needs.
❌ Ignoring quota reports until storage becomes full.
✅ Always review quota reports until storage becomes full.
❌ Applying quotas without communicating policies to users.
✅ Test before applying quotas without communicating policies to users.
Interview Questions¶
Beginner¶
- What is a disk quota?
- What is the difference between user and group quotas?
- What is a soft limit?
- What is a hard limit?
Intermediate¶
- How do you enable quotas on a filesystem?
- What is the purpose of
quotacheck? - How do you configure quotas for a user?
- What does
repquotadisplay?
Architect Level¶
- How would you implement quotas on a shared enterprise file server?
- How would you design storage policies for hundreds of developers?
- How would you monitor quota usage across multiple Linux servers?
Summary¶
In this lesson, you learned:
- Disk quota fundamentals
- User and group quotas
- Soft and hard limits
- Grace periods
- Enabling quotas
- Managing quota usage
- Production storage policies
Disk quotas are an essential storage management feature that helps administrators control disk usage, ensure fair resource allocation, and prevent storage exhaustion on multi-user Linux systems.
Key Takeaways¶
- Disk quotas control storage usage for users and groups.
- Soft limits provide warnings and allow temporary overuse.
- Hard limits prevent further storage allocation.
- Enable quota support using
usrquotaandgrpquota. - Use
edquotato configure limits. - Monitor storage consumption regularly using
quotaandrepquota.
What's Next?¶
Backup Basics — Protecting Data in Linux
You'll explore:
- Why backups are essential
- Types of backups (Full, Incremental, and Differential)
- Backup strategies
- Local and remote backups
- Backup tools in Linux
- Backup verification
- Recovery fundamentals
- Backup best practices
By the end of the lesson, you'll understand how to design reliable backup strategies, create backups using common Linux tools, and ensure data can be restored quickly in the event of hardware failures, accidental deletions, or system disasters.