Prerequisites
Before setting up quotas, make sure you have:
- SSH access to your VPS
- Root or sudo privileges
- Separate home partition (quotas work on mounted filesystems)
Step 1: Check if Quotas are Enabled
Connect to your VPS:
ssh hxroot@YOUR_SERVER_IP -p 22
mount | grep -E "usrquota|grpquota"
If you see usrquota in mount options, quotas are ready.
Step 2: Enable Quotas on Filesystem (if not already)
Edit /etc/fstab:
sudo nano /etc/fstab
Find the line for /home and add usrquota,grpquota:
/dev/sda1 /home ext4 defaults,usrquota,grpquota 0 0
Remount the partition:
sudo mount -o remount /home
Step 3: Create Quota Database Files
sudo quotacheck -cug /home
sudo quotacheck -avug
Step 4: Enable Quotas
sudo quotaon -avug
Step 5: Set Quota for a User
sudo edquota -u username
This opens an editor. Set soft and hard limits (in KB):
Filesystem blocks soft hard inodes soft hard
/dev/sda1 2048000 5120000 6144000 123456 0 0
- soft – Warn user before reaching hard limit
- hard – Absolute limit (cannot exceed)
- blocks – Disk space (1 block = 1KB, so 5GB = 5242880)
- inodes – Number of files/directories (0 = unlimited)
Step 6: Set Grace Period (Time allowed over soft limit)
sudo setquota -t 86400 86400 /home
86400 seconds = 24 hours.
Per-user grace period:
sudo edquota -T username
Step 7: View Quotas
Check all quotas:
sudo repquota -a
Check user quota:
sudo quota -u username
User checks their own quota:
quota -s
Step 8: Set Same Quota for Multiple Users (Prototype)
Set quota for a prototype user, then copy:
sudo edquota -p prototypeuser targetuser1 targetuser2 targetuser3
Disable Quotas for a User
sudo setquota -u username 0 0 0 0 /home
Check Quota Status
sudo quotaon -p /home
✅ Disk quotas configured. Users are now limited to their allocated storage space.