Sunday, July 3, 2011

Solaris File system Quotas


A frequent source of grief for the UNIX administrator is the management of shared disk space. Users all too often consume all available disk space, thus precipitating errors for everyone using that filesystem. Unfriendly users can disrupt other users' work by deliberately filling a shared filesystem with one or more large files. Disk quotas can be used to limit the amount of disk space each user is allowed to use. This is the procedure for setting up a filesystem for quota use.
1. The mount option quota must be added to /etc/vfstab or the appropriate automount map. Here is an example vfstab entry.

/dev/dsk/c0t1d0s7 /dev/rdsk/c0t1d0s7 /export/home ufs 2 yes quota

2. As root, create a file called quotas in the root directory of the filesystem (in this case, /export/home/quotas). In this example, use the command touch /export/ home/quotas.

3. Set up a prototype quota entry for a single user with the edquota command. An example entry:

fs /export/home blocks (soft = 8000, hard = 9999) inodes (soft = 800, hard = 999)
In this example, the user's soft disk space limit is 8,000 blocks (times 512 bytes equals 4 MB); the hard disk space limit is 9,999 blocks (5 MB). The soft inode limit (the number of files the user may own) is 800, and the hard limit is 999.
When a user exceeds a soft limit, a dialogue box is displayed in Figure.  When a user exceeds a hard limit, the user will not be able to create files. The error message seen is "Disc quota exceeded."

4. Replicate the prototype entry to other users as needed with the edquota command. An example command is

# edquota -p phil mary john sue rick larry ralph april
In this example, the quotas values for user phil are replicated to users mary, john, sue, rick, larry, ralph, and april.
5. Activate quotas with the quotaon command.
6. Build initial quota statistics with the quotacheck command.
7. Create a quota report with the repquota command. Here is a sample report.

# repquota -a
/dev/dsk/c0t1d0s7 (/export/home):
Block limits File limits
User used soft hard timeleft used soft hard timeleft
phil +- 17402 999 99999 7.0 days 197 9999 9999

In this example, user phil has exceeded his block limit quota; files owned by phil are taking too much disk space. This is signified both by the "+ -" symbol and by the "timeleft" field for block limits on the report.

No comments:

Post a Comment