Disk Quota Management

As far as you have you own system and if a single user then you can
use any amount of space without any restriction. Since Linux major use is the ability to support multiuser you may need to have some
restriction in the amount of disk space the user takes up.

I am going to explain you how to manage disk quota in this document.

Enter single user mode

This is the first step you got to do. Enter into single user mode, this
is not a must if you are sure that no one else is logged in except you.
But its always safe to do so.

# init 1    to enter into single user mode

# who       to find who else is logged in the server

Edit fstab

once you have logged in as single user or sure that you are the only user
then edit the file /etc/fstab.fstab contains the details about the partitions, their file system and their properties.

you must have already planned the partition that is to be given for the users
to make use of. Most of the time it is the /home partition which is set for
quota usage. Now edit the fstab /home properties with usrquota in addition to the default property.

it should look as follows

LABEL=/home   /home    ext3    defaults        1 2

and you change it as

LABEL=/home   /home    ext3    defaults,usrquota 1 2

remount the file system

Since you have make this changes, remount the file system in order to have

this changes take effect.

#mount -o remount /home

And exit single user mode.

# exit  or # init 3

create the configuration files

Now create the configuration file in the top most directory of the file system
that is defined for quota usage. Since you have defined /home create the file aquota.user and aquota.group (if needed) under /home and chmod them to 600.

#cd /home

#touch aquota.user aquota.group

#chmod 600 aquota.user aquota.group

Initialize the configuration files

These files are checked before any space changes are done for a user. To initialize the file run the following command. (it will throw err when you enter the command for the first time)

#quotacheck -vagum

Edit the limits

With the edquota command that opens a editor, you can edit the limit for each user.

# edquota -u <user>

this will show a editor with following info

Disk quotas for user act3user (uid 503):

File system  blocks       soft       hard     inodes     soft     hard

/dev/hda3       24          0          0          7        0        0

# Blocks: The amount of space in 1K blocks the user is currently using.

# Inodes: The number of files the user is currently using.

# Soft Limit: The maximum blocks/inodes a quota user may have on a partition. The role of a soft limit changes if grace periods are used. When this occurs, the user is only warned that their soft limit has been exceeded. When the grace period expires, the user is barred from using additional disk space or files. When set to zero, limits are disabled.

# Hard Limit: The maximum blocks/inodes a quota user may have on a partition when a grace period is set. Users may exceed a soft limit, but they can never exceed their hard limit.

The grace period can be set with the command which like above shows a editor

#edquota -t

Filesystem             Block grace period     Inode grace period

/dev/hda3                     7days                  7days

The same command goes for editing the group quota with the option -g

#edit -g <group>

To view the whole quota information of the file system you have the repquota command.

#repquota /home

Conclusion

The quota limit is a important topic set the users to use a specfic amount of disk space. This solves the problem of some user eating up most of the disk resources and you will know exactly when a disk is to be added to the box.