Saturday, October 17, 2009

Quota Configuration

Once you have quotas set up on the server, whether they are user or group quotas, you will need to test them to verify they are working correctly. Set the quota for a user and then add file space as that user to verify that quotas are changing in the process.
One command that I always liked ot use is repquota. For example if your quotas are on the /home directory run this command:

repquota /home
That should show current status and keep up to date with changes. This will confirm both user and group quotas.
Turn Quotas Off
This command turns quotas off.
quotaoff -vaug
quotas may be enabled again by running the command
quotaon
Maintain Quotas
The quotacheck command must be run on a regular basis to maintain the quotas that have been set. Use this command in a crontab -e or in one of the following files to regularly run the command. It will mean that the commands are much more accurate.
quotacheck -avug

2 comments:

  1. There are a number of excellent quota commands that will help you get the job done quickly. You will want to practice these commands so that you can use them quickly when you need to as users will probably see it a crisis situation when they cannot save when they go over the quotas you set.



    quota
    -u check quotas for a user
    -g check quotas for a group
    -q show file systems where the user is over the limit

    Example:
    quota -u tom

    repquota
    This command creates a summary of quotas on a file system.
    -u report on quotas for a user
    -a report on quotas for entire file system
    -v report all quotas even if no usage
    -g report quotas for groups

    Example:
    repquota /home

    edquota
    This provides a way to edit quotas for users.
    -u edit user
    -g edit group
    -t edit soft limit time
    -p setup a policy for another user

    In this example the already established policy for fred is given to mary. This is a way to create a standard policy.

    edquota -p fred mary

    Another way of setting quotas is with the setquota command.
    setquota
    -u user
    -g group
    -t set grace period

    setquota -u joe 2000 6000 0 0 /home

    quotacheck

    The following options can be employed with the command quotacheck to gain information for managing the server, run only when the file system is unmounted in most cases. The file system is not ready to run quotas until the quotacheck command is run to see what disk space is already used.
    Commands Descriptions
    -a scan for quotas by checking the /etc/mtab file
    -v verbose scan
    -u scan for user quotas
    -g scan for group quotas
    -m remounts a scanned filesystem

    If you run a command like this (only run it on an umounted system), it will check all the above:
    quotacheck -avugm /home

    This command will check the /etc/mtab.
    If the quotas were setup correctly there should be a aquota file in the directory that the quotas were setup on. Try this command for quotas on the /home directory, assuming /home is on a separate partition.

    ls -la /home/aquota.*
    You should see the output that the file exists, either called aquota.user (for user quotas) or aquota.group (for group quotas). These are binary files that store disk usage in the top level of the partitions.

    ReplyDelete
  2. Create User Quotas
    Add a User
    useradd tom

    Edit /etc/fstab to enable user quotas

    vi /etc/fstab

    If the /home directory was created with LVM it will look like this:
    /dev/VolGroup00/LogVol00 /home ext3 defaults 1 1

    If you are not using LVM it but have a label it will look like this:
    LABEL=/home /home ext3 defaults 1 1

    Now change the default line above which is for a Logical Volume to the one below which enables quotas.

    /dev/VolGroup00/LogVol00 /home ext3 usrquota 1 1

    Save the change and then remount the /home directory.

    mount -o remount /home

    Start the quotacheck

    Change to init level 1

    init 1

    Run the quotacheck command:

    quotacheck -cug /home

    Return to runlevel 5 or runlevel 3.

    init 5

    Turn the quota on

    quotaon /home

    Set user quota specifics. Here the setquota command is used and a soft limit of 200 and a hard limit of 800 is set. Yes, this is very small but it provide a way for you to test how it all works as the limits are hit quickly in testing. You want to be very familiar with how it all works before you roll it out to your users.

    setquota -u tom 200 800 0 0 /home

    Test your settings as tom

    su – tom

    quota (this will show current quotas for the user)

    dd if=/dev/zero of=filespace bs=1k count=150

    Each time you increase space usage run quota to see the changes.

    dd if=/dev/zero of=filespace bs=1k count=900

    Once you are done with testing be sure you understand how to increase or decrease limits on your system. Both of the options can be performed with the edquota command and the “-u” option so that you can modify the resources for a user.

    edquota -u fred
    This command will open up fredś quota file which has seven columns. The top of the file will list the userś name and UID.
    The first column will list the directory file system. This is usually in the format of the partition that the quotas are on. An example:
    /dev/hda6
    The second column lists the number of blocks that are currently used by the user. These are 1KB blocks. An example:
    4485296
    This is almost 4.5 GB.
    The next two columns represent the soft and hard limits for the users. 0 means that the user has no limits. 4000000 in the soft limit means that when the user reaches 4 GB they will activate a message that they are in violation of their quota. The grace period set in days gives this user the opportunity to make changes to move under the soft limit. Once the grace period is over, the user will be forced to make the necessary changes.
    The hard limit represents a boundary that the user will not be able to cross. Administrators do not need to set hard limits unless the grace period is used. If an administrator does not use the grace period the result will be that the soft limit will be the boundary for users.
    Typically, users appreciate a reasonable boundary with a warning system so that in the middle of an important project they are not forced with deleting data before they can save. Of course there are always the users that will push it to the limit.

    ReplyDelete