Manage Users with Quotas

by Mike on October 6, 2009

in Server Management

Quotas Mini-Course
The quotas mini-course is designed to help you implement quotas for users and groups.  Quotas are a way to guarantee  resources for your users.  The guarantee of resources to your users is fundamental to good system administration.  When users run out of space there is always trouble and you can be sure as administrator that trouble will be pointed at you.  Whenever you implement quotas with users it is a good idea to create soft limits which provide them a warning for 7 days but during that time they can still save.  Certainly some users will ignore the soft limit and push to the hard limit where they cannot go over the limit and can lose data because they cannot save.

Course Difficulty
This course is for new administrators or home administrators with little experience.  Working out quotas on a test box first is highly recommended.

Course Support
You can find support where you can ask questions in the forum.

Course Outline
Manage Users with Quotas
Verify Quota Configuration
Quota Commands
User Quotas
Group Quotas
Profiles
Quiz

centos_server

The Linux kernel must be able to support quotas.
Install quotas
yum install quotas

Check to see if the quota rpm is installed
rpm -qi quota
Find a list of tools that are associated with quota
rpm -ql quota

Commands                         Description
/sbin/quotaon /fs             This command will enable quotas for the filesystem.
/sbin/quotaoff /fs             This command will disable quotas for the filesystem.
/usr/sbin/edquota username    Edit the quotas for a specific user.
/usr/bin/quota                  Users can review the quotas set for them.
/usr/sbin/repquota          Generates a report of disk usage by users.
/sbin/quotacheck            Checks for quota usage

When the computer starts there is a script that will check to see if /etc/fstab has been modified to provide quotas. This script will run the two commands needed to enable quotas; quotacheck and quotaon. The script is found at /etc/rc.sysinit if you would like to view it.

Edit /etc/fstab
In order for a directory to use quotas it must be set up in the /etc/fstab file. The file system which you place quotas on must be unmounted and then remounted for quotas to work. Here is the process (for the /home directory):
Be careful, make a backup of /etc/fstab before making modifications. In the example below the upper line shows the default, the lower line shows the modifications to begin the process of setting up quotas. The second line sets up user quotas, the third line sets up user quotas and group quotas.
/dev/hda7   /home    ext3    defaults                                1 2
#####################################
/dev/hda7   /home    ext3    exec,dev,suid,rw,usrquota               1 2
#####################################
/dev/hda7   /home    ext3    exec,dev,suid,rw,usrquota,grpquota      1 2
Once the changes have been made, (you made a backup right?), then restart the system to remount the quotas after being setup.
touch /home/aquota.user
chmod 600 /home/aquota.user

mount -o remount /home

quotaon -avug /home
quotacheck -augm /home
This must be done after you have set up quotas on the file system of your choice.

Previous post:

Next post: