A disk quota is nothing but a limit set by a sys admin that restricts certain aspects of file system usage on UNIX operating systems. Both UFS and ZFS support the disks quota for user. Under UFS you can set the number of blocks and inodes that can be used by a user on a file system such as /export/home:
Block quota, limits the amount of disk space that can be used.
Inode quota, limits the number of files and directories that can be created.
Quota Limits
The number of blocks and inodes is often specified with both soft and hard values:- Soft value or soft limits - It may be temporarily exceeded and the user will be warned about the violation. In addition, administrators usually define a warning level, or soft quota, at which users are informed they are nearing their limit, that is less than the effective limit, or hard quota. There may also be a small grace interval, which allows users to temporarily violate their quotas by certain amounts if necessary.
- Hard limits - are those that cannot be exceeded and attempts to use more blocks or inodes beyond a user's hard limit will be denied.
Step # 1: Configure /export/home
Edit /etc/vfstab, enter:# vi /etc/vfstab
Update /export/home as follows:
/dev/dsk/c0d0s7 /dev/rdsk/c0d0s7 /export/home ufs 2 yes rqrq mount options enables disk quota for /export/home. This make sure that disk quota enabled after each reboot.
Step # 2: Remount File System
Type the following command to mount /export/home with quota:# mount -o remount,quota /export/home
Step # 3: Create Empty Quotas File
You need to create empty quotas file in in root of file system i.e. create /export/home/quotas# touch /export/home/quotas
# chown root:root /export/home/quotas
# chmod 0600 /export/home/quotas
Step # 4: Set User Quota
You edit and set user quotas for user vivek using edquota command.# edquota username
# edquota vivek
edquota is a quota editor. One or more users may be specified on the command line. For each user a temporary file is created with an ASCII representation of the current disk quotas for that user for each mounted ufs file system that has a quotas file, and an editor is then invoked on the file. The quotas may then be modified, new quotas added, etc. Upon leaving the editor, edquota reads the temporary file and modifies the binary quota files to reflect the changes made. To make any changed to user quota use the same command again.
Step # 5: Turn on User Quota
The quotaon command turns on disk quotas for /export/home ufs file systems. Type the command:# quotaon -v /export/home
Sample Outputs:
/export/home: quotas turned on
How Do I Display a User's Quota and Usage?
The quota command display a user's ufs file system disk quota and usage. Run it as follows:# quota -v username
# quota -v vivek
The repquota command displays a summary of the disk usage and quotas for the specified ufs file systems such as /export/home, enter:
# repquota /export/home
To display quota information of all users, type:
# repquota -va
Testing
The user vivek will get an error message if the quota has been exceeded. You can test this with the following simple command (try creating 500M file in a home directory):# su - vivek
$ dd if=/dev/zero of=bigfile bs=1024 count=512000
Alternatively, you can use mkfile to create a file called bigfile
$ mkfile 500m bigfile
No comments:
Post a Comment