В началоUnix Toolbox → 19. DISK QUOTA
Gentoo-doc HOME Пред.: 18. DATABASESВ началоУровень выше: Unix ToolboxСлед.: 20. SHELLS

19. 19. DISK QUOTA

A disk quota allows to limit the amount of disk space and/or the number of files a user or (or member of group) can use. The quotas are allocated on a per-file system basis and are enforced by the kernel.

19.1. 19.1 Linux setup

The quota tools package usually needs to be installed, it contains the command line tools. Activate the user quota in the fstab and remount the partition. If the partition is busy, either all locked files must be closed, or the system must be rebooted. Add usrquota to the fstab mount options, for example:

/dev/sda2 /home reiserfs rw,acl,user_xattr,usrquota 1 1

# mount -o remount /home

# mount # Check if usrquota is active, otherwise reboot

Initialize the quota.user file with quotacheck.

# quotacheck -vum /home

# chmod 644 /home/aquota.user # To let the users check their own quota

Activate the quota either with the provided script (e.g. /etc/init.d/quotad on SuSE) or with

quotaon:

quotaon -vu /home

Check that the quota is active with:

quota -v

19.2. 19.2 FreeBSD setup

The quota tools are part of the base system, however the kernel needs the option quota. If it is

not there, add it and recompile the kernel.

options QUOTA

As with Linux, add the quota to the fstab options (userquota, not usrquota):

/dev/ad0s1d /home ufs rw,noatime,userquota 2 2

# mount /home # To remount the partition

Enable disk quotas in /etc/rc.conf and start the quota.

# grep quotas /etc/rc.conf

enable_quotas="YES" # turn on quotas on startup (or NO).

check_quotas="YES" # Check quotas on startup (or NO).

# /etc/rc.d/quota start

19.3. 19.3 Assign quota limits

The quotas are not limited per default (set to 0). The limits are set with edquota for single

users. A quota can be also duplicated to many users. The file structure is different between the

quota implementations, but the principle is the same: the values of blocks and inodes can be

limited. Only change the values of soft and hard. If not specified, the blocks are 1k. The grace

period is set with edquota -t. For example:

# edquota -u colin

Linux

Disk quotas for user colin (uid 1007):

Filesystem blocks soft hard inodes soft hard

/dev/sda8 108 1000 2000 1 0 0

FreeBSD

Quotas for user colin:

/home: kbytes in use: 504184, limits (soft = 700000, hard = 800000)

inodes in use: 1792, limits (soft = 0, hard = 0)

For many users

The command edquota -p is used to duplicate a quota to other users. For example to duplicate

a reference quota to all users:

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

# edquota -p refuser user1 user2 # Duplicate to 2 users

Checks

Users can check their quota by simply typing quota (the file quota.user must be readable). Root

can check all quotas.

# quota -u colin # Check quota for a user

# repquota /home # Full report for the partition for all users

Пред.: 18. DATABASESВ началоУровень выше: Unix ToolboxСлед.: 20. SHELLS
В началоUnix Toolbox → 19. DISK QUOTA