Having a disk quota on a shared system is very useful, you can control how much data each user can store on the system. In this tutorial I will assume that you have many partitions on your system, we will work with the home directory partition for your Linux system.
Do the following:
Step 1)
touch /home/aquota.user
chmod 600 /home/aquota.user
Step 2)
Edit the /etc/fstab file, we want to add "usrjquota=aquota.user,jqfmt=vfsv0" as an option for the home partition such that the home partition line looks like the following line:
/dev/sda7 /home ext3 defaults,usrjquota=aquota.user,jqfmt=vfsv0 1 1
Step 3)
You can choose to reboot the system to update the changes we just made or run this command "mount -o remount /home" which will remount the partition with the changes.
Step 4)
We need to do a quota check which will calculate how much disk space each user is currently using. So run the following line:
quotacheck -vuma
Step 5)
We need to turn quota on, so run this line:
quotaon -avu
Step 6) Last step
We need to set a quota for each user on the Linux system run edquota followed by the username.
Example "edquota pywong"
You should see something like this:
Disk quotas for user pywong (uid 1128):
Filesystem blocks soft hard inodes soft hard
/dev/sda7 473452 1000000 1500000 476 0 0
/dev/sdb1 296004 15000000 20000000 413 0 0
/dev/sdb2 0 0 0 0 0 0
When we use the edquota command this will most likely open it using a text editor called vi, you many need to read up on how to use vi for editing if you do not already know how to use it.
We want to edit the Filesystem line that matches our line for the home directory, in this case it’s the line with /dev/sda7, we want to edit the soft column and the hard column. 1000000 = 1GB and 1500000 = 1.5GB. You want the hard quota to be bigger than the soft quota, when user hit the soft quota they will get warning and if they hit the hard quota they will get error messages and the system will not let the user write anymore files.
Leave a Reply