Implementing Disk Quotas
April 22, 2008 by gopalkoduri
[From gopi's garage] You might be in a good need to restrict others from using up more than the disk space they actual need. Or you may need to have restricted disk usage for a system which has more users and you cant really afford 50 GB each. Here we’ll see an easy how to of setting up and managing the disk quotas in linux.
For this, fire up the package manager of your distro (yum/synaptic/emerge/apt/yast etc…) and get a package called ‘quota’ installed.
Ok.. now decide the partitions you wish to provide restricted usage on. let’s say they are /dev/sda1 & /dev/sd4 and say their mount points are /home and /media/storage respectively.
Open /etc/fstab file with any editor and identify the lines which correspond to mounting them. They look something like this…
LABEL=/home /home ext3 defaults 1 2 /dev/sda4 /media/storage ext3 defaults 1 2
Change them by including usrquota along with defaults. and now it should look like this..
LABEL=/home /home ext3 defaults,usrquota 1 2 /dev/sda4 /media/storage ext3 defaults,usrquota 1 2
Wow.. everything seems well! Now just remount those partitions.. with this command (dont forget to place in the proper path to the partition you want to unmount!)
root@localhost# mount -o remount /home root@localhost# mount -o remount /media/storage
You have just made sure that partitions are capable of implementing the quotas.. congrats! We’ll now get to something we have been waiting.. before that just one more thing.. run this command so that your system knows what is the systems current disk usage map. (again don’t forget to place in the correct paths)
root@localhost# touch /home/aquota{.user,.group}
#this is for user file for independent user quotas and
root@localhost# touch /media/storage/aquota{.user,.group}
#for group file for group quotas
root@localhost# quotacheck -vagum
#please see man page for what those options are for.
Thats it! now just one more step to specify which user gets what and you are done…
root@localhost# edquota -u <username>
This will open your default text editor (specified by EDITOR environment variable in your session) and show some info like this…
Disk quotas for user guest (uid 1001): Filesystem blocks soft hard inodes soft hard /dev/sda1 379144 0 0 3599 0 0
What this data says is this :
First Column : the partition which is in use and supports disk quota Second Column : no.of 1KB blocks the user currently is using. Third Column : Soft limit in 1KB blocks (user warned when he exceeds this) Fourth Column : Hard limit in 1KB blocks (NOT to exceed this!) Fifth Column : No.of files user currently had. Sixth Column : Soft limit in terms of no. of files Seventh Column : Hard limit in terms of no. of files
so you now know what to do… go ahead and save your world! If you still feel too lazy about that.. OK.. here goes an example.. I will restrict the above user to use 2.5 GB disk space and give 500 MB grace for, say 10 days. Is that ok ? anyways.. here we go..
Disk quotas for user guest (uid 1001): Filesystem blocks soft hard inodes soft hard /dev/sda1 379144 2500000 3000000 3599 0 0
Ok.. but where the hell I specified the grace TIME ?? for that, just run the edquota -t and when it opens similar setup, set the value, which is quite straight forward, to 10days. (no gap between 10 and days please. btw, other units are seconds, minutes, hours, days, weeks, months).
Happy days!



hey, i hope you wouldn’t mind if i put rewrite of this tutorial for fedora on my collection of howtos for fedora (http://fedora.co.in/) obviously with proper doc license, copyrights and credits for you.
Sure.. I would be delighted..