In addition to monitoring the disk space used by the system, you can also limit the disk space by implementing the disk quota. Therefore, when the user uses too much disk space or partitions, the system administrator will receive a warning. The disk quota can be configured for individual users or user groups. This flexibility can assign a small quota to each user to process "personal" files (such as emails and reports ), it also allows the project they are working on to have a large quota (assuming the project has its own group ). In addition, the quota can be set to control the number of disk blocks used.
In addition to monitoring the disk space used by the system, you can also limit the disk space by implementing the disk quota. Therefore, when the user uses too much disk space or partitions, the system administrator will receive a warning.
The disk quota can be configured for individual users or user groups. This flexibility can assign a small quota to each user to process "personal" files (such as emails and reports ), it also allows the project they are working on to have a large quota (assuming the project has its own group ).
In addition, the quota can be set not only to control the number of disk blocks used, but also to control the number of inner nodes. Because the internal node contains file-related information, the control of the internal node can control the number of files that can be created.
To implement disk quota, quota RPM must be installed on the system.
6.1. Configure Disk Quota
To implement the disk quota, follow these steps:
Modify/etc/fstab to enable the quota for each file system
Remount the File System
Create a quota file and regenerate the disk table
Allocate quota
The preceding steps are described in detail in the following sections.
6.1.1. Enable quota
Use your favorite editor as the root user to add the usrquota and (or) kgquota options to the file system that requires the quota:
LABEL = // ext3 defaults 1 1 LABEL =/boot ext3 defaults 1 2 none/dev/pts devpts gid = 5, mode = 620 0 0 LABEL =/home ext3 defaults, usrquota, kgquota 1 2 none/proc defaults 0 0 0 none/dev/shm tmpfs defaults 0 0/dev/hda2 swap defaults 0 0 0/dev/cdrom/mnt/cdrom udf, iso9660 noauto, owner, kudzu, ro 0 0/dev/fd0/mnt/floppy auto noauto, owner, kudzu 0 00
In the preceding example, the/home file system enables user and group quotas.
6.1.2. Remount the File System
After the userquota and kgquota options are added, Remount the file system with each corresponding fstab entry modified. If a file system is not used by any process, use the umount command followed by the mount command to re-mount the file system. If a file system is in use, the easiest way to re-mount the file system is to reboot the system.
6.1.3. Create a quota File
After each quota-enabled file system is remounted, the system can now use the disk quota. However, the file system itself does not yet support quotas. The next step is to run the quotacheck command.
The quotacheck command checks the quota-enabled file system and creates a table for each file system for the current disk. This table is used to update the disk usage file of the operating system. In addition, the disk quota file of the file system is also updated.
To create a quota file (aquota. user and aquota. group) on the file system, use the-c option of the quotacheck command. For example, if the/home partition is enabled for both the user and group quota, create these files in the/home directory:
Quotacheck-acug/home
-Option a means that all mounted non-NFS file systems in the/etc/mtab will be checked to determine whether the quota is enabled. -C option specifies that the quota file should be created for each file system with the quota enabled. The-u option specifies to check the user quota, and the-g option specifies the inspection group quota.
If the-u or-g option is specified, only the user quota file is created. If only the-g option is specified, only the group quota file is created.
After the file is created, run the following command to generate the current disk usage table for each file system with the quota enabled:
Quotacheck-avug
The options are as follows:
A-check all locally mounted file systems with quotas Enabled
V-detailed status information is displayed during quota check.
U-check the user's disk quota Information
G-Disk Quota information of the inspection group
After quotacheck is run, data for each file system (such as/home) with the quota enabled (user and/or group) is written into the quota file.