Difference between revisions of "Disk quota"

From ArchWiki
Jump to: navigation, search
m (Example setup: clarification)
m (quotas=quota when possible)
Line 3: Line 3:
 
From [[Wikipedia:Disk quota|Wikipedia]]:
 
From [[Wikipedia:Disk quota|Wikipedia]]:
 
:"''A '''disk quota''' is a limit set by a system administrator that restricts certain aspects of file system usage on modern operating systems. The function of setting quotas to disks is to allocate limited disk-space in a reasonable way.''"
 
:"''A '''disk quota''' is a limit set by a system administrator that restricts certain aspects of file system usage on modern operating systems. The function of setting quotas to disks is to allocate limited disk-space in a reasonable way.''"
This article covers the installation and setup of disk quotas.
+
This article covers the installation and setup of disk quota.
  
 
==Installing==
 
==Installing==
Disk quotas only require one package:
+
Disk quota only require one package:
 
  # pacman -S quota-tools
 
  # pacman -S quota-tools
  
 
==Enabling==
 
==Enabling==
''For journaled quotas, see the notes in [[#Journaled quotas]].''
+
''For journaled quota, see the notes in [[#Journaled quota]].''
  
 
1. First, edit {{filename|/etc/fstab}} to enable the quota mount option(s) on selected file systems:
 
1. First, edit {{filename|/etc/fstab}} to enable the quota mount option(s) on selected file systems:
Line 26: Line 26:
 
   # mount -vo remount /home
 
   # mount -vo remount /home
  
4. Create the quota index to enable quotas:
+
4. Create the quota index:
 
   # quotacheck -vgum /home
 
   # quotacheck -vgum /home
 
:or for all partitions with the quota mount options in {{filename|/etc/mtab}};
 
:or for all partitions with the quota mount options in {{filename|/etc/mtab}};
Line 34: Line 34:
 
   # quotaon -av
 
   # quotaon -av
  
{{tip|to automatically enable quotas on boot, add the previous command to {{filename|/etc/rc.local}}.}}
+
{{tip|to automatically enable quota on boot, add the previous command to {{filename|/etc/rc.local}}.}}
  
===Journaled quotas===
+
===Journaled quota===
Enabling journaling for disk quotas adds the same benefits journaled file systems do for forced shutdowns; the data is less likely to become corrupt.
+
Enabling journaling for disk quota adds the same benefits journaled file systems do for forced shutdowns, meaning that data is less likely to become corrupt.
  
Setting up journaled quotas is the same as above, except for the mount options:
+
Setting up journaled quota is the same as above, except for the mount options:
 
  /dev/sda1 /home ext4 defaults''',usrjquota=aquota.user,jqfmt=vfsv0''' 1 1
 
  /dev/sda1 /home ext4 defaults''',usrjquota=aquota.user,jqfmt=vfsv0''' 1 1
 
or aditionally enable the group quota mount option;
 
or aditionally enable the group quota mount option;
Line 79: Line 79:
 
  # quota -g $GROUP
 
  # quota -g $GROUP
  
===Copying quotas===
+
===Copying quota settings===
 
The idea is to make a temporary user acount, modify the quota settings for that user, and then copy the generated quota files for all users to use. After setting quota settings for ''quotauser'', copy the settings:
 
The idea is to make a temporary user acount, modify the quota settings for that user, and then copy the generated quota files for all users to use. After setting quota settings for ''quotauser'', copy the settings:
 
  # edquota -p '''quotauser''' `awk -F: '$3 > 999 {print $1}' /etc/passwd`
 
  # edquota -p '''quotauser''' `awk -F: '$3 > 999 {print $1}' /etc/passwd`

Revision as of 04:12, 9 December 2009

From Wikipedia:

"A disk quota is a limit set by a system administrator that restricts certain aspects of file system usage on modern operating systems. The function of setting quotas to disks is to allocate limited disk-space in a reasonable way."

This article covers the installation and setup of disk quota.

Installing

Disk quota only require one package:

# pacman -S quota-tools

Enabling

For journaled quota, see the notes in #Journaled quota.

1. First, edit Template:Filename to enable the quota mount option(s) on selected file systems:

 /dev/sda1 /home ext4 defaults 1 1
edit it as follows;
 /dev/sda1 /home ext4 defaults,usrquota 1 1
or aditionally enable the group quota mount option;
 /dev/sda1 /home ext4 defaults,usrquota,grpquota 1 1

2. Create the quota files in the file system:

 # touch /home/aquota.user
 # touch /home/aquota.group     # For group quota

2. The next step is to remount:

 # mount -vo remount /home

4. Create the quota index:

 # quotacheck -vgum /home
or for all partitions with the quota mount options in Template:Filename;
 # quotacheck -vguma

5. Finally, enable quotas:

 # quotaon -av
Tip: to automatically enable quota on boot, add the previous command to Template:Filename.

Journaled quota

Enabling journaling for disk quota adds the same benefits journaled file systems do for forced shutdowns, meaning that data is less likely to become corrupt.

Setting up journaled quota is the same as above, except for the mount options:

/dev/sda1 /home ext4 defaults,usrjquota=aquota.user,jqfmt=vfsv0 1 1

or aditionally enable the group quota mount option;

/dev/sda1 /home ext4 defaults,usrjquota=aquota.user,grpjquota=aquota.grp,jqfmt=vfsv0 1 1

Configurating

Replace Template:Codeline as appropiate, and edit the quota as root: Template:Command

blocks
1k blocks
inodes
Number of entries in directory file
soft
Max number of blocks/inodes user may have on partition before warning is issued and grace period countdown begins. If set to "0" (zero) then no limit is enforced.
hard
Max number of blocks/inodes user may have on partition. If set to "0" (zero) then no limit is enforced.
Note: to edit group quotas, use Template:Codeline.

Example setup

Editing the limits as below, for example:

Disk quotas for user testuser (uid 1000):
Filesystem      blocks       soft       hard     inodes     soft   hard       
/dev/sda1       695879       10000      15000     6741        0      0

sets the following restrictions: the Template:Codeline limit means that once testuser uses over 10MB of space a warning email gets ensued, and after a period of time the soft limit gets enforced. The Template:Codeline limit is stricter, so to speak; a user cannot go over this limit.

To alter the Template:Codeline limit grace period:

# edquota -t

Managing

Checking for quota limits and advanced operations

Basics

Use this command to check for quotas on a specific partition:

# repquota /home

Use this command to check for all quotas that apply to a user:

# quota -u $USER

for groups;

# quota -g $GROUP

Copying quota settings

The idea is to make a temporary user acount, modify the quota settings for that user, and then copy the generated quota files for all users to use. After setting quota settings for quotauser, copy the settings:

# edquota -p quotauser `awk -F: '$3 > 999 {print $1}' /etc/passwd`

This applies the settings to users with a UID equal to or greater than 1000.

Other commands

There are several useful commands:

repquota -a      # Shows the status on diskusage
warnquota        # Can be used to warn the users about their quota
setquota         # Non-interactive quota setting--useful for scripting

Lasty, Template:Codeline is used to give thorough information about the quota system: Template:Command

More resources