Section 10.3. Some User Is Taking Too Much Disk Space

10.3. Some User Is Taking Too Much Disk Space

Disk space is relatively inexpensive. However, it's finite. No matter how much disk space you add, users can find ways to occupy it with their files. For example, users who download big files such as movies or ISO files with Linux distributions (hint, hint) may consume several gigabytes of space for each file.

10.3.1. Space Management

As an administrator, you need to know whether users need more space. You need to know how to regulate the space allowed to different users. As the Linux administrator, you could periodically peruse the files in your users' home directories, and you technically have permissions to edit and even delete users' files. But your users and management might not appreciate that kind of administration; it may even violate corporate policies.

There are a number of things you can do. For example, you can regulate the space associated with user-accessible directories, specifically the /home and /tmp directories. You can configure these directories in dedicated partitions; if one or more users then overload these partitions, the data does not spill over to other parts of the operating system. Conceivably, you can even configure a dedicated partition for a specific user.

The standard Linux method for regulating the space taken by a user uses quotas . Without quotas, users can go wild and load all the space available on your servers.

When you configure a quota, you're regulating either the space or the number of files, as defined by their inodes, in each partition mounted in /etc/fstab.

If you're implementing user-based limits for the first time, be prepared for negative reactions. Explain what you're doing. Help your users with alternatives for all of their data.

10.3.2. Quotas in the Kernel

Quotas are enabled by default on modern stock Linux kernels. However, many Linux geeks build their own kernels, as discussed in Chapter 7. If you've built your own kernel and forgot to enable quotas, you won't be able to get them to work, no matter how you configure quotas. That could be supremely annoying.

To make sure your kernel supports quotas, check the associated kernel configuration file. For example, on my Debian computer, I can see if quotas are allowed with the following command:

 grep QUOTA /boot/config-2.6.8-mj1 

The output is:


Kernel settings are configured directly into the kernel (y), configured as modules (m), or disabled (n).

10.3.3. Installing Quota Packages

The quota packages are installed by default on our selected distributions. However, you'll want to make sure they're up-to-date. On Debian Linux, I can do so with the following command:

 apt-get install quota quotatool 

Alternatively, once you've confirmed installation (rpm -q quota), you can use the yast2 online_update command to start SUSE's update tool. Normally, all current packages (except the kernel) should be updated automatically if a newer version is available. If necessary, you can use the search function to see whether the quota package requires an update.

For Red Hat Enterprise Linux, assuming you have a subscription to the Red Hat Network, the update command is simple:

 up2date -u quota 

For Fedora Linux, you can use the same command as Red Hat Enterprise Linux, or use the following yum command to check your current repositories for available quota package updates:

 yum update quota 

10.3.4. Quotas in Start Scripts

The common theme on our selected Linux distributions is that they run the quotacheck and quotaon commands. The first ensures that disk consumption records are up-to-date, and the second starts enforcement of the quotas.

Red Hat/Fedora handles quota start scripts somewhat differently from Debian and SUSE. The Red Hat/Fedora script that activates quotas is /etc/rc.sysinit. This script is run by /etc/inittab as the "System Initialization" script, and checks and activates scripts during each boot with the quotacheck and quotaon commands.

Debian and SUSE Linux start quotas in fairly standard scripts in the /etc/init.d directory. SUSE uses the script boot.quota, and Debian uses quota. In either case, the responsible script runs the quotacheck and quotaon commands to manage quotas.

10.3.5. Quotas When Mounting

To configure quotas in Linux, you'll need to configure appropriate options in /etc/fstab. Typically, quotas are configured on the partition mounted on the /home directory. Fortunately, the process is the same for all our selected distributions.

For the purpose of this annoyance, I'm assuming that you've configured a separate partition for the /home directory and want to regulate the space taken by users and groups on that partition. If /home is not mounted on a separate partition, you can certainly configure quotas on the partition with the parent directory, such as the top-level root directory (/).

Typical Red Hat/Fedora directives in /etc/fstab are slightly different from other distributions, in that standard mount directories are associated with the partition devices with a label. For example, the following line from a Red Hat Enterprise Linux 4 /etc/fstab file associates the /home directory with a partition so labeled.

 LABEL=/home         /home         ext3        defaults        1 2 

You can find the partition associated with a specific directory in /etc/mtab.

Alternatively, many Red Hat/Fedora systems are configured with Logical Volumes. Unless specifically labeled, the associated devices are listed in /etc/fstab, with a line similar to:

 /dev/VolGroup00/LogVol00     /home         ext3        defaults        1 2 

Normally, on Debian and SUSE Linux, each mounted partition is specifically defined by device, with a line similar to:

 /dev/hda2      /home         ext3        defaults,errors=remount-ro     1 2 

The errors=remount-ro directive supports remounting the partition in read-only mode if errors are detected.

Whatever the distribution, user and group quotas are configured as a mount option in /etc/fstab. To understand how this works, you need to know the available mount options. Some of the more important options are shown in Table 10-1.

Table 10-1. Mount options in /etc/fstab




Reads and writes data at different times (asynchronously)


Searches through /etc/filesystems for a compatible filesystem; contrast with noauto


Includes async, auto, dev, exec, nouser, suid, and rw


Supports access to character devices such as terminals; supports block access to drives


Specifies what is done if there is an error; a common setting is errors=remount-ro for remounting a partition as read-only


Allows binaries; contrast with noexec


Supports group-based quotas


Remounts a currently mounted filesystem; often done with the mount command with different mount options


Mounts read-only


Mounts with read/write permissions


Allows SUID or SGID permissions


Supports reads and writes to disk at the same time


Allows regular users to mount this filesystem; common on filesystems such as CD/DVD drives


Supports user-based quotas

To support quotas, you'll need to add the appropriate mount option. For example, if you want to add user and group quotas to the above mounts of the /home directory, you'd modify those lines as shown here. For /home partitions with a label, use:

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

For /home partitions mounted on a logical volume, use:

 /dev/VolGroup00/LogVol00   /home   ext3    defaults,usrquota,grpquota    1 2 

For /home partitions mounted on a specific partition, use:

 /dev/hda2  /home  ext3  defaults,errors=remount-ro,usrquota,grpquota     1 2 

Once you've configured quotas (as I'll describe shortly) and modified the appropriate /etc/fstab lines, you can force your system to reread the line with the following command:

 mount -o remount /home 

If you've implemented quotas on a different partition, substitute for /home accordingly.

10.3.6. Quota Management Files

Before you can start configuring quotas, you'll need to create quota-management files in the associated directory. One method of doing so is with the quotacheck command. One command that I run is the following:

 quotacheck -ugm /home 

Note the use of the -u, -g, and -m switches:

  • With the -u switch, quotacheck scans for user quotas. If quotas don't already exist, it adds the appropriate user quota file (aquota.user on Fedora/Red Hat and SUSE; quota.user on Debian).

  • With the -g switch, quotacheck scans for group quotas. If quotas don't already exist, it adds the appropriate group quota file ( on Fedora/Red Hat and SUSE; on Debian).

  • With the -m switch, quotacheck remounts the scanned filesystem.

User quotas are saved in the aquota.user or quota.user configuration file (depending on distribution and version), which is in binary format.

10.3.7. Quota Configuration Commands

Once you've installed the appropriate packages and configured quotas in /etc/fstab, you can start configuring quotas for individuals and groups.

The standard method is with the edquota command: edquota -u username for users, and edquota -g groupname for groups.

You can also use setquota to configure quotas for one or more users or groups. In my opinion, edquota does a better job helping someone visualize quota settings.

When I run the eduquota -u columbia command, I get some data that may look a bit strange, similar to what you see here:

 Disk quotas for user columbia (uid 1014):   Filesystem         blocks    soft    hard    inodes    soft    hard   /dev/hda7           10920       0       0       401       0       0 

What you actually see in a default 80 x 25 terminal reflects line wrapping. (If you're running a terminal in the GUI, you can remove the wrapping by increasing the width of the terminal.)

This data illustrates quotas for user columbia on a filesystem mounted on /dev/hda7. You can make changes, as edquota opens the desired quota file in the vi editor. Quotas are based on hard and soft limits. If you expand the console, you'll be able to see the seven columns, as defined in Table 10-2.

Table 10-2. Quotas defined




Specifies the partition associated with this filesystem.


Notes the number of blocks (1k) taken by the user/group.


The first Soft column specifies the space limit for the user/group.


The first Hard column specifies the absolute space limit for the user/group, during a grace period.


Notes the number of inodes taken by the user/group; corresponds to the number of files.


The second Soft column specifies the maximum number of inodes for the user/group.


The second Hard column specifies the maximum number of inodes for the user/group, during a grace period.

Soft limits specify the space or inodes allocated on a permanent basis by user or group. If there's a grace period, hard limits can be set a bit higher. After the grace period expires, the user or group has to delete enough files to get back within the soft limits as configured. If the user does not take the responsibility to remove the extra space or inodes during the grace period, the account does not allow writes until the user has done so.

You can edit the quotas associated with a group. For example, for the special group created in the first annoyance in this chapter, you can edit its quotas with the following command:

 edquota -g winos 

You're taken to a configuration file similar to that shown earlier.

10.3.8. Quota Grace Periods

If you've set soft and hard limits for users and/or groups, you'll want to set a grace period. The standard is seven days, as you can see when you run the following command:

 edquota -t 

You can specify a different grace period for the amount of space (Block Grace Period) and number of files (Inode Grace Period).

On older Linux systems, there is one idiosyncrasy: the quota system doesn't work if you have a space in the grace periode.g., a standard one-week grace period is 7days, not 7 days.

10.3.9. Applying Quotas to Others

Naturally, as a geek, you may need to apply quotas to multiple users. You could edit each user's quota individually, but that would be time-consuming. Alternatively, you can apply quotas to several users with the edquota -up command, which takes one user quota and applies it to the others in the list. For example, the following command takes the quota configured for user columbia and applies it to the users napa, sonoma, and willamette:

 edquota -up columbia napa sonoma willamette 

10.3.10. Quota Reports

Naturally, once you've configured quotas, you may want to check their status periodically, to make sure they are meeting the needs of you and your users. If you see lots of users nearing their quota limits, you may need more space. If you have a few users near their limits, you may wonder if they're storing appropriate information in their home directories and if they have legitimate needs.

Anyone can get a quota report for his own account. For example, as user michael, I can get my own quota report with the following command:

 quota -v 

Try this command on your own system. It should look familiar. It is a readout of the quota, similar to what you edited earlier with the edquota command.

Naturally, you may want to get quota reports for multiple users; this can be done with repquota -a.

For more information on administering quotas, see

Linux Annoyances for Geeks
Linux Annoyances for Geeks: Getting the Most Flexible System in the World Just the Way You Want It
ISBN: 0596008015
EAN: 2147483647
Year: 2004
Pages: 144
Authors: Michael Jang © 2008-2017.
If you may any questions please contact us: