Setting Filesystem Quota in linux

I recently activated quota on my slicehost slice and it was quite simple and fast to do. The only disadvantage is that I needed to set quota on the only filesystem I had, which is /. If there is a choice then it is advisable to set quota on non-root filesystem such as /home, /var etc. The primary reason for this is that while performing the quota check the filesystem needs to be mounted read-only temporarily by the quotacheck utility. Since the root filesystem can not be mounted read-only while the system is running we need to do a force quota check on the system which might result in in-accurate figures and can cause corruption to the quota files.

Here are the commands which I executed in quick succession to enable the quota:

$ sudo modprobe quota_v2
$ sudo lsmod|grep quota
quota_v2               11392  0
$ sudo mount -o remount,noatime,usrquota,grpquota /

The following command will create the quota files and the -m option is to force the execution as the filesystem can not be mounted read-only.

$ sudo quotacheck -cugm / 

Now to calculate the current usage,

$ sudo quotacheck -avugm
quotacheck: Scanning /dev/sda1 [/] done
quotacheck: Checked 8990 directories and 87482 files

Now to set the quota for user testuser we can use setquota. Following command set the quota to 1GB.

$ sudo setquota -u testuser 1000000 1048576 0 0 -a
This entry was posted in FLOSS and tagged , . Bookmark the permalink.

Leave a Reply