|Internet Business Consultant|
|Home||Blog||Bio||Projects||Contact||Latest Blog (new site): How to Get to Genius|
Disk space can be restricted by implementing disk quotas so that the system administrator is alerted before a user consumes too much disk space or a partition becomes full.
Disk quotas can be configured for individual users as well as user groups. This kind of flexibility makes it possible to give each user a small quota to handle "personal" file (such as email and reports), while allowing the projects they work on to have more sizable quotas (assuming the projects are given their own groups).
In addition, quotas can be set not just to control the number of disk blocks consumed but to control the number of inodes. Because inodes are used to contain file-related information, this allows control over the number of files that can be created.
The quota RPM must be installed to implement disk quotas. For more information on installing RPM packages, refer to Part III Package Management.
To implement disk quotas, use the following steps:
Each of these steps is discussed in detail in the following sections.
As root, using a text editor, edit the /etc/fstab file and add the usrquota and/or grpquota options to the file systems that require quotas:
In this example, the /home file system has both user and group quotas enabled.
After adding the userquota and grpquota options, remount each file system whose fstab entry has been modified. If the file system is not in use by any process, use the umount command followed by the mount to remount the file system. If the file system is currently in use, the easiest method for remounting the file system is to reboot the system.
After each quota-enabled file system is remounted, the system is capable of working with disk quotas. However, the file system itself is not yet ready to support quotas. The next step is to run the quotacheck command.
The quotacheck command examines quota-enabled file systems and builds a table of the current disk usage per file system. The table is then used to update the operating system's copy of disk usage. In addition, the file system's disk quota files are updated.
To create the quota files (aquota.user and aquota.group) on the file system, use the -c option of the quotacheck command. For example, if user and group quotas are enabled for the /home partition, create the files in the /home directory:
The -a option means that all mounted non-NFS file systems in /etc/mtab are checked to see if quotas are enabled. The -c option specifies that the quota files should be created for each file system with quotas enabled, the -u specifies to check for user quotas, and the -g option specifies to check for group quotas.
If neither the -u or -g options are specified, only the user quota file is created. If only -g is specified, only the group quota file is created.
After the files are created, run the following command to generate the table of current disk usage per file system with quotas enabled:
The options used are as follows:
After quotacheck has finished running, the quota files corresponding to the enabled quotas (user and/or group) are populated with data for each quota-enabled file system such as /home.
The last step is assigning the disk quotas with the edquota command.
To configure the quota for a user, as root in a shell prompt, execute the command:
Perform this step for each user who needs a quota. For example, if a quota is enabled in /etc/fstab for the /home partition (/dev/hda3) and the command edquota testuser is executed, the following is shown in the editor configured as the default for the system:
The first column is the name of the file system that has a quota enabled for it. The second column shows how many blocks the user is currently using. The next two columns are used to set soft and hard block limits for the user on the file system. The inodes column shows how many inodes the user is currently using. The last two columns are used to set the soft and hard inode limits for the user on the file system.
A hard limit is the absolute maximum amount of disk space that a user or group can use. Once this limit is reached, no further disk space can be used.
The soft limit defines the maximum amount of disk space that can be used. However, unlike the hard limit, the soft limit can be exceeded for a certain amount of time. That time is known as the grace period. The grace period can be expressed in seconds, minutes, hours, days, weeks, or months.
If any of the values are set to 0, that limit is not set. In the text editor, change the desired limits. For example:
To verify that the quota for the user has been set, use the command:
Quotas can also be assigned on a per-group basis. For example, to set a group quota for the devel group, use the command (the group must exist prior to setting the group quota):
This command displays the existing quota for the group in the text editor:
Modify the limits, save the file, and then configure the quota.
To verify that the group quota has been set, use the command:
To assign quotas based on each file system enabled for quotas, use the command:
Like the other edquota commands, this one opens the current quotas for the file system in the text editor:
Change the block grace period or inode grace period, save the changes to the file, and exit the text editor.
Services: Internet Marketing Web Marketing
|Electric Speed: Search Engine Optimization Techniques|