To set disk quota for a file system in Linux, you need to follow these steps:
/etc/fstab file to include the usrquota and/or grpquota options for the desired file system.Example:
/dev/sda1 /home ext4 defaults,usrquota,grpquota 0 2
After editing /etc/fstab, remount the file system or reboot the system:
mount -o remount /home
sudo apt-get install quota # For Debian/Ubuntu
sudo yum install quota # For RHEL/CentOS
quotacheck command to scan the file system and create quota files (aquota.user and aquota.group):sudo quotacheck -cug /home
sudo quotaon /home
edquota command to set quotas for a specific user or group. For example, to set a quota for user john:sudo edquota john
This opens an editor where you can set:
Example configuration in the editor:
Disk quotas for user john (uid 1001):
Filesystem blocks soft hard inodes soft hard
/dev/sda1 1024 5000 10000 100 200 500
Save and exit the editor.
quota command to check the quota for a user:sudo quota -u john
repquota to view quotas for all users on the file system:sudo repquota /home
quotacheck periodically.If you are managing a shared file system for a team and want to limit each user's disk usage to 10GB, you would set the soft and hard limits to 10GB (10240 blocks, assuming 1 block = 1KB) for each user using edquota.
If you are using Tencent Cloud's Cloud Virtual Machine (CVM) or CBS (Cloud Block Storage) services, you can apply these disk quota settings to the file systems on your CVM instances. For scalable storage needs, consider using Tencent Cloud File Storage (CFS), which supports quota management and is suitable for shared file systems.