Atomic Disk Quotas

J

Jarret W. Buse

Guest
Atomic Disk Quotas

Disk Quotas are the ability to set limits on a user or group of users as to how much disk space they can use.

By setting the amount that a user or group can use, you can control how full a harddisk can get, but hopefully not down to 0 KB.

NOTE: Most harddisks should always contain about 5 GB of free space (on a 500 GB drive, or about 1%). Some people say 10% of the drive should be free, but on most systems the performance does decrease when the drive is too full.

Once quotas are set, the file system tracks the amount of data written by each user and group. Every time a user creates, modifies or deletes a file, the used amount is updated. When a user or group attempts to change or add a file which will cause the quota to be exceeded, a message appears to warn the user that the disk is full.

For example, a quota is set for User1 to only be allowed 1 GB of space. When User1 checks the drive size, the disk capacity will only show 1 GB for the drive as a whole. If User1 has used 955 MB and then attempts to write a 50 MB file, which would exceed the quota, User1 receives an error that the file cannot be written since the disk is full.

On some file systems that use disk quotas, a process is executed in the background when the processor's load is low to update the used amounts. If User1 writes a file that puts the used amount from 900 MB to 980 MB, until the amount is updated, the file system still sees that User1 has 100 MB allowed on the disk. A file system like XFS uses Atomic Disk Quotas. This means that the used disk space is updated in real-time. The amount of space used by a user or group should never be incorrect when a write is allowed and performed.

Most file systems track the space usages for users and groups within files on the harddisk that are accessible by a user. Some file systems, such as XFS, stores the information internally and are not accessible. The internal files are made up of metadata information for the file system.

Two types of limits can be set:
  • Soft limits
    • Users can have a grace period to exceed quotas
  • Hard limits
    • Once grace period is over, excess space is denied
    • Users must delete files to allow further writes

Quotas on XFS file systems are enabled when mounted such as:
  • uquota – User quotas
  • gquota – Group quotas

NOTE: The noenforce quota type can be used to stop quota limits, but still allow for reporting of disk usage by user or group.

To report disk usage on a disk named ‘xfsdisk’ use the following command:

Code:
xfs_quota -c 'report -h' /xfsdisk

NOTE: To report or set any quotas, the drive must be mounted.

Once quotas are enabled, after mounting, the xfs_quota tool can be used to set limits or report on space usage.

User limits can be set with the following command:

Code:
limits xfs_quota -x -c 'limit bsoft=1500m bhard=1700m username'

NOTE: Use ‘m’ for megabytes and ‘g’ for gigabytes when setting quota limits.

Group limits can be set with the following command:

Code:
xfs_quota -x -c 'limit -g bsoft=1500m bhard=1700m groupname'

Other commands within xfs_quota can be used as follows:

  • enable – enable quota limits
  • disable – turn off all quotas
  • remove – all quotas are removed (the limits are destroyed and must be set again if enabled)
  • off – quota management is turned off, but limits are not destroyed

Users can obtain feedback on their quota by running:

Code:
xfs_quota -c quota

Some file systems, such as XFS also provide quotas for projects. Project and Group quotas cannot be enabled at the same time.

Projects are initialized by:

Code:
xfs_quota -c 'project -s projectname'

The project name is set up in the /etc/projects/ directory.

Once initialized, the project is enabled by using:

Code:
xfs_quota -x -c 'limit -p bsoft=1500m bhard=1700m projectname'

Project quotas on XFS file systems are enabled when mounted with:

  • pquota

The command would be:

Code:
mount -o pquota device mountpoint
 

Attachments

  • slide.jpg
    slide.jpg
    13.7 KB · Views: 103,244

Members online


Top