I. File Systems
6. Implementing Disk Quotas
6.2. Managing Disk Quotas
If quotas are implemented, they need some maintenance — mostly in the form of watching to see if the quotas are exceeded and making sure the quotas are accurate. Of course, if users repeatedly exceeds their quotas or consistently reaches their soft limits, a system administrator has a few choices to make depending on what type of users they are and how much disk space impacts their work. The administrator can either help the user determine how to use less disk space or increase the user’s disk quota if needed.
6.2.1. Reporting on Disk Quotas
Creating a disk usage report entails running therepquota utility. For example, the command repquota /homeproduces this output:
*** Report for user quotas on device /dev/hda3 Block grace time: 7days; Inode grace time: 7days
Block limits File limits
User used soft hard grace used soft hard grace
---
root -- 36 0 0 4 0 0
tfox -- 540 0 0 125 0 0
testuser -- 440400 500000 550000 37418 0 0
To view the disk usage report for all quota-enabled file systems, use the command: repquota -a
While the report is easy to read, a few points should be explained. The--displayed after each user is a quick way to determine whether the block or inode limits have been exceeded. If either soft limit is exceeded, a+appears in place of the corresponding-; the first-represents the block limit, and the second represents the inode limit.
Thegracecolumns are normally blank. If a soft limit has been exceeded, the column contains a time specification equal to the amount of time remaining on the grace period. If the grace period has expired,noneappears in its place.
6.2.2. Keeping Quotas Accurate
Whenever a file system is not unmounted cleanly (due to a system crash, for example), it is necessary to runquotacheck. However,quotacheckcan be run on a regular basis, even if the system has not crashed. Running the following command periodically keeps the quotas more accurate (the options used have been described in Section 6.1.1 Enabling Quotas):
Chapter 6. Implementing Disk Quotas 25 The easiest way to run it periodically is to usecron. As root, either use thecrontab -ecommand to schedule a periodicquotacheckor place a script that runsquotacheckin any one of the following directories (using whichever interval best matches your needs):
• /etc/cron.hourly • /etc/cron.daily • /etc/cron.weekly • /etc/cron.monthly
The most accurate quota statistics can be obtained when the file system(s) analyzed are not in active use. Thus, the cron task should be schedule during a time where the file system(s) are used the least. If this time is various for different file systems with quotas, runquotacheckfor each file system at different times with multiple cron tasks.
Refer to Chapter 37 Automated Tasks for more information about configuringcron.
6.2.3. Enabling and Disabling
It is possible to disable quotas without setting them to be 0. To turn all user and group quotas off, use the following command:
quotaoff -vaug
If neither the-uor-goptions are specified, only the user quotas are disabled. If only-gis specified, only group quotas are disabled.
To enable quotas again, use thequotaoncommand with the same options. For example, to enable user and group quotas for all file systems: quotaon -vaug
To enable quotas for a specific file system, such as/home: quotaon -vug /home
If neither the-uor-goptions are specified, only the user quotas are enabled. If only-gis specified, only group quotas are enabled.
6.3. Additional Resources
For more information on disk quotas, refer to the following resources.
6.3.1. Installed Documentation
26 Chapter 6. Implementing Disk Quotas
6.3.2. Related Books
• Red Hat Enterprise Linux Introduction to System Administration; Red Hat, Inc. — Available at http://www.redhat.com/docs/ and on the Documentation CD, this manual contains background in- formation on storage management (including disk quotas) for new Red Hat Enterprise Linux system administrators.
Chapter 7.
User-Defined Device Names
The/dev/directory contains virtual files that represent devices. Each virtual file represents a device for the system such as a storage device, USB device, or printer. These virtual files are called device names.
Device names for IDE devices begin withhd, and device names for SCSI devices begin withsd. The prefix is followed by a letter, starting with a, that represents the drive order. For example,/dev/hda is the first IDE hard drive,/dev/hdbis the second IDE hard drive,/dev/hdcis the third IDE drive, and so on.
If the device name is followed by a number, the number represents the partition number. For example, /dev/hda1represents the first partition on the first IDE drive.
If a hard drive is physically moved to a different location in the machine, is removed, or fails to initialize, some of the device names will change, potentially leaving device name references invalid. For example, as shown in Figure 7-1, if a system has three SCSI hard drives, and the second SCSI hard drive is removed,/dev/sdcbecomes/dev/sdb, causing any references to/dev/sdcto become invalid and any references to/dev/sdbinvalid as well since it is a different drive.
/dev/sda /dev/sdb /dev/sdc
/dev/sda /dev/sdb
Figure 7-1. Removing a Hard Drive
Every hard drive has a unique identifier associated with it, called a UUID. To solve the problem of changing device names,devlabelallows for user-defined device names that are associated with these UUIDs. A symbolic link is created from the user-defined device name to the actual device name. If the actual device name changes, the symbolic link is updated to point to the same drive according to its UUID. Thus, both IDE and SCSI storage devices can be referenced by their user-defined names. Devlabelalso allows for automatically mounting hotplug devices such as removable hard drives and USB devices such as memory cards for digital cameras. If configured to mount automatically, after the device is plugged in, it is mounted with the user-defined device name.
7.1. ConfiguringDevlabel
User-defined device names can be added based on the device name, partition name, or the UUID of the drive.
Use the following syntax to add a user-defined device name for a storage device. The device specified can be the entire device or a single partition on a device.
28 Chapter 7. User-Defined Device Names