104.4. Manage disk quotas
Weight: 1
Description: Candidates should be able to manage disk quotas for users.
Key Knowledge Areas:
Set up a disk quota for a filesystem
Edit, check and generate user quota reports
Terms and Utilities:
quota
edquota
repquota
quotaon
Quotas allow us to control disk usage by user or by group. Quotas prevent individual users and groups from using a larger portion of a filesystem than they are permitted, or from filling it up altogether. Here for LPIC2 exam we use quota version 2 with kernel 2.4 and above.
[In this Lesson we will enable and set quota on /dev/sdb1 with ext4 file system.]
Checking for the quota package
Quota package is not installed since quotas are not part of the usual default desktop install. Use dpkg
or rpm
to check that you have the package installed.
Adding quota support to /etc/fstab
First step to enable quotas is to add the appropriate options to the filesystem definitions in /etc/fstab, according to whether we want to implement user quotas, group quotas.
option
meaning
usrquota
Enable user quotas
grpquota
Enable group quotas
So for enabling quotas on sdb1 we need to edit the line we have previously added to /etc/fstab (ubuntu 16.04):
After editing /etc/fstab and add quotas, we need to remount the filesystems.
mount -o remount /dev/sdb1
user quota information is stored in the aquota.user file in the root of the filesystem, and group quota is similarly stored in aquota.group.
after we remount the filesystem, we must create the quota files and enable quota checking.
quotacheck
The quotacheck
command checks the quotas on all filesystems and creates the required aquota.user and aquota.group files if they do not exist. It can also repair damaged quota files.
quotacheck switch
meaning
-a
Check all mounted filesystems in /etc/mtab (except NFS filesystems)
-c
Ignore existing quota files. Run a new scan and write the results to disk
-u
Check user quotas (this is the default)
-g
Check group quotas
-v
Verbose output
aquota.user and aquota.group have been made.
aquota.user and aquota.group are both binary files and should not be edited by hand.
Turning quota on /off
quotaon
The quotaon command enables disk quotas for one or more file systems specified by the FileSystem parameter. The specified file system must be defined with quotas in the /etc/filesystems file, and must be mounted.
The quotaon command looks for the quota.user and quota.group files in the root directory of the associated file system, and will return an error if not found.
The common options -a
, -g
, -u
, and -v
have the same meaning as for the quotacheck command
. Similarly, if you do not specify the -a
option, you must specify a filesystem. Use the -p
option if you just want to display whether quotas are on or off.
quotaoff announces to the system that the specified filesystems should have any disk quotas turned off.
Setting quota limits
edquota
Quotas are controlled either through binary files in the root of the filesystem or through filesystem metadata. To set a quota for a particular user, use the edquota
command. This command extracts the quota information for the user from the various filesystems with quotas enabled, creates a temporary file, and opens an editor for us to adjust the quotas.
use the
-u
option (default) with one or more user names.To edit group quotas, use the
-g
with one or more group names.
edquota
displays my current usage of both 1K blocks and inodes on each of the filesystems that have quota turned on.
You can think of block limits as an approximate limit on the amount of data that a user may store, and inode limits as a limit on the number of files and directories.
There are also soft and hard limits for both block and inode usage. In this example, these are 0, meaning no quota limit is enforced.
soft limit vs hard limit
The soft limit is the value at which a user will receive email warnings about being over quota. The hard limit is the value that a user may not exceed.
The grace period
Users or groups may exceed their soft limit for a grace period, which defaults to seven days. After the grace period, the soft limit is enforced as a hard limit. Once the hard limit is reached, some files must be deleted before new files can be created.
Set grace periods using edquota -tedquota-t
. Again, you will be placed in an editor:
now lets set some hard limits on inodes on /dev/sdb1 for user1:
and lets check it :
For copying one user quota limits to the other user, use -p switch:
edquota ‑p user1 user2 user2
Quota reports
quota
The quota
command with no options displays the quotas for the a user on any filesystems (quota shoud have been set for that user and he or she must have some files on it):
The
-v
option displays the information for all filesystems that have quota enabled.
Checking user quotas one user at a time is not very useful, so you will want to use the repquota
command to generate quota reports.
repquota
repquota stands for report for quota. This will display filesystem usage and quota information on your system.
-a
option produces a report for all mounted filesystems that have quota enabled. The-v
option produces more verbose
That's all!
.
.
.
Warning users
The warnquota
command is used to send email warnings to users who are over quota. When a group is over quota, the email is sent to the user specified in /etc/quotagrpadmins for the group. The format of the email is controlled by the file /etc/warnquota.conf. The file /etc/quotatab is used to map names such as /dev/sdc6 to more user-friendly descriptions such as “Shared EXT3 filesystem.” Normally warnquota
is run periodically as a cron
job( will be discussed later).
.
https://developer.ibm.com/tutorials/l-lpic1-104-4/
https://www.ibm.com/support/knowledgecenter/ssw_aix_71/q_commands/quotaon.html
https://linux.101hacks.com/unix/repquota/
.
Last updated