Linux quotas

Hardware Related Tasks

Linux allows you to manage disk quotas, create backups, and manage storage devices through the use of commands, utilities, and scripting. Tasks including disk usage, backup process, and logical volume management are discussed in the following sections.

Managing Disk Usage with Quotas

Disk quotas allow you to limit the amount of space a given user can utilize. This is very important when you have multiple users on the same server. You would not want to allow one user to take up all the space on your hard drive. You can establish disk quotas with Linux, and it is actually a pretty simple process, but first you have to make sure your system supports quotas. If not, you can install that support with a single command.


yum install quota

This process is shown in Figure 7.7 using Fedora with KDE desktop.

Image from book
Figure 7.7: Installing quota support.

With openSUSE, the command is


Yast2 -i quota

This is shown in Figure 7.8.

Image from book
Figure 7.8: Installing quota support with openSUSE.

As you can see, the essence of the command for your distribution is to use your distributions installer program (yum or yast2) and its install command (for example, install or -i).

Now that you have quota support installed, you need to enable quotas. You started by editing file /etc/fstab to add qualifier usrquota or grpquota to the partition.

To enable quota support on a filesystem, add defaults and usrquota or grpquota to the fstab entry for that partition. Like this:


/dev/hda1    /home  ext3   defaults,usrquota
/dev/hda2    /home  ext3   defaults,grpquota
/dev/hda3    /home  ext3   defaults,usrquota,grpquota

This enables user and group quotas to have support on the /home directory. Of course, you could set quotas on other directories, but since all user home directories should be under /home, this is the most logical place to establish quotas. Now we have to set up the quota file:


touch /home/aquota.user

or if it is a group:


touch /home/aquota.group

The quota file should be owned by root, so let’s change its permissions:


chmod 600 /home/aquota.user

Now if you reboot and check your mounted partitions in mtab, you should see something like this:


/dev/hda1 /home ext3 rw,usrquota 0 0

Now, assuming you installed the quota support that was described at the beginning of this section, you can check quotas with this command:


quotacheck -v

You can now edit the quotas with any editor you like or use the edquota shell command:


edquota -u user_id

Note that the user_id will be the user’s name, like jsmith.

When you are finished, your quota file will look something like this:


Disk quotas for user user_id (uid 601):
Filesystem       blocks     soft     hard    inodes    soft    hard
/dev/hda1        1840       0        0       80        0       0

In case any of these entries are not familiar to you, the following list defines them.

  • blocks: The hard drive uses blocks of 1KB in size. So allocating 1,000 of those would allocate 1MB.

  • inodes: This defines the number of entries in a directory file.

  • soft: The soft is a “soft limit.” It is the number of blocks/inodes the user may have on a partition before a warning is issued and the grace period begins. If it is set to 0, then no limit is enforced.

  • hard: A hard limit means that this limit on the number of blocks/inodes that the user may have on a partition is absolute with no warning or grace period. You would want it to be larger than the soft limit. If it is set to 0, then no limit is enforced.

  • grace: This is a grace period; it is a time (in seconds, minutes, hours, weeks, or months) before the limit will be enforced. It is not shown in the previous example because that shows default settings. It is shown in the following example.

This is an example of how this might look once you have made some changes:


Filesystem blocks  quota  limit   grace   files   quota   limit   grace
/dev/hda6  992     25000  25000   7 days  71      10000   11000

There are a variety of quota related shell commands shown here:

  • quotaon: This turns filesystem quotas on.

  • quotaoff: This turns filesystem quotas off.

  • quota: This shell command displays the current user’s quota limits.

    -g will display quotes for any group the current user is a member of.

    -q provides a briefer display with fewer details.

  • edquota: This command is used to edit user quotas, as you saw previously.

    -g is used to edit group quotas.

    -t edits the time limits.

    -u is used to edit user quotas, but it can be omitted because it is the default.

  • setquota: This command is used to set quotas.

    -r is used for remote quotas.

    -u is used for user quotas, but it can be omitted because it is the default.

    -g is used for group quotas.

  • quotacheck: You use this command to check quotas.

    -v will display what it finds as it goes. Normally, quotacheck operates silently.

    -u will only check user quotas. This is the default.

    -g will only check group quotas.

This list of commands, and their options, is not meant to be exhaustive, but just the most commonly used.


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章