Debian FTP Server Disk Quota Configuration Guide
Disk quotas help control disk space usage by FTP users, preventing any single user from monopolizing storage. Below are step-by-step instructions to set up user and group quotas on a Debian FTP server.
First, install the quota package (mandatory for quota management) and optionally quota-nls (for localized error messages). Run:
sudo apt update
sudo apt install quota quota-nls
/etc/fstab for Quota SupportEdit the /etc/fstab file to enable user (usrquota) and/or group (grpquota) quotas for the partition hosting FTP files (e.g., /home). Locate the target partition (e.g., /dev/sda1) and append the options:
/dev/sda1 /home ext4 defaults,usrquota,grpquota 0 2
Save changes and exit the editor.
Apply the new mount options without rebooting by remounting the partition:
sudo mount -o remount /home
Create the quota database files (aquota.user for users, aquota.group for groups) using quotacheck. The -c flag creates new databases, -u enables user quotas, -g enables group quotas, and -m forces a check even if the system is running:
sudo quotacheck -cum /home
Start the quota service to enforce limits immediately:
sudo quotaon -vug /home
The -v flag shows verbose output, -u enables user quotas, and -g enables group quotas.
Use edquota to set soft (warning threshold) and hard (strict maximum) limits for users/groups. Replace username with the actual FTP user’s name:
sudo edquota -u username
This opens an editor with a section like this:
Disk quotas for user username (uid 1000):
Filesystem blocks soft hard inodes soft hard
/dev/sda1 10240 51200 65536 100 200 250
blocks: Current disk usage (in KB).soft: Warning threshold (e.g., 50GB soft limit = 51200 blocks × 1KB).hard: Maximum allowed space (e.g., 60GB hard limit = 65536 blocks × 1KB).inodes: Limits for the number of files (adjust similarly).Save and exit to apply changes. For group quotas, use edquota -g groupname.
Check a user’s quota usage with:
quota -u username
For a summary of all users, run:
quota -vug /home
The repquota command provides a detailed report:
sudo repquota /home
If using vsftpd (common for Debian FTP servers), edit its configuration file to enable quota integration:
sudo nano /etc/vsftpd.conf
Add/modify these lines:
quota_enable=YES
quota_file=/var/lib/vsftpd/quota.user
quota_group_enable=YES
quota_group_file=/var/lib/vsftpd/quota.group
Restart vsftpd to apply changes:
sudo systemctl restart vsftpd
/home and /dev/sda1 with your FTP directory and partition as needed.cron to automate quota checks (e.g., daily):sudo crontab -e
Add:0 0 * * * /usr/sbin/quotacheck -cum /home
0 0 * * * /usr/sbin/quotaon -vug /home
By following these steps, you can effectively manage disk space usage on your Debian FTP server and prevent abuse.