A Little About Linux: Disk Quotas

I'll make no bones about it, I've never needed to use disk quotas in Linux for all of the years I've been working with it, possibly because I've been in a mixed Windows/Linux environment and all the quotas were on the Windows boxes, or perhaps I've not had enough users, but I've never used them in production so far.  However, they can be really useful if you have multiple users logging on and you want to stop their home directories expanding or you're using a Samba server and want to stop users using all of the space up.   

Most of the standard Linux file systems allow for quotas to be set, but they need to be configured in the kernel in some instances.  Most distros have this enabled by default.

Configuring and Enabling Quotas
For any partition you wish to create a quota for, you must add an extra option where it's defined in /etc/fstab.  For User Quotas (quotas based on a user account) or Group Quotas (quotas based on the members of a group) you would either add usrquota or grpquota as shown below;

A standard fstab entry for the /dev/sdb1...
/dev/sdb1    /data1    ext4    defaults                          0 0

An fstab entry with user and group quota support enabled for /dev/sdb1...
/dev/sdb1    /data1    ext4    defaults,usrquota,grpquota        0 0

Once configured, unmount and than remount the partition to enable the quotas.

Then, make sure that the quota is enabled after a reboot;
chkconfig quota on

Next, run the quotacheck command to create the quota database.  -c creates the quota files and -u and -g are for users and groups;
quotacheck -cug /dev/sdb1

Once created, run;
quotacheck -avug /dev/sdb1

Finally set the quotas for either users or groups;
edquota johng
edquota -g johngroup

In both cases you will be presented a text editor screen with the existing options that you can change.

To enable or disable a quota;

To report on quota disk usage use;

No comments: