With massive hard drives, one might be tempted to think disk quotas a thing of the past. However, with larger capacity comes larger amounts of data, and in multiuser systems, one user can easily consume more drive space than they should, preventing other users from utilizing storage space.
Using disk quotas is easy and is especially useful to keep the digital pack-rats from claiming more space than they should. As well, you can set soft and hard quotas — soft quotas to remind individuals that they are nearing their capacity and hard quotas to enforce that maximum capacity.
Quotas are defined per-filesystem. Most distros support quotas, although not all do it out-of-the-box, and you may have to install the quota package. To enable quota support, edit /etc/fstab as root and add the usrquota and grpquota options to the filesystems you wish to enable quota support for. For instance:
/dev/md5 /home xfs defaults,nosuid,nodev,usrquota,grpquota 1 2
Once you have made the changes, remount the filesystem(s) you have changed:
# mount -o remount /home
To check that quota support is indeed enabled, execute:
# quotacheck -augmv
This will instruct quotacheck to check all filesystems for user and group quotas without remounting them as read-only. The first time quotacheck is run, it will display a number of errors because it has never checked the systems before. Now you can enable quotas with the quotaon command:
# quotaon -augv
Once quotas have been turned on, use edquota to edit the quotas for a particular user:
# edquota -u joe
This will open the default system editor (usually vim) where you can edit the hard and soft limits for both blocks and inodes for each filesystem that supports quotas.
You can then view current quota usage by using the repquota tool:
# repquota -a
Once a soft quota has been exceeded, the user is notified once that they have exceeded their quota, but will be able to continue writing to the system unless they reach the hard quota; at which point, any new files created will be 0 bytes in size. You can determine whether or not to allow this default behavior by changing the grace time; the default is seven days. For the time of the grace period, if the soft quota is exceeded, the user can continue to write files, unless they hit the hard limit. After the grace period, they will no longer be able to write files.
With a combination of soft and hard limits and a decent grace time for users, administrators can ensure that individual pack rats will not negatively affect other users' fair share of storage space.
Delivered each Tuesday, TechRepublic's free Linux NetNote provides tips, articles, and other resources to help you hone your Linux skills. Automatically sign up today!