How do I configure file system quotas to control how much available storage space can be used on a given UFS file system (such as /export/home) under Solaris UNIX operating systems?
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.
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.
The quota system on ufs, zfs and vxfs filesystems to put limits on resources of a filesystem. Most of the actions listed in this FAQ are written with the assumption that they will be executed by the root user running the ksh or bash shell. Also, only super-user root can set disk quota.
Edit /etc/vfstab, enter:
# vi /etc/vfstab
Update /export/home as follows:
/dev/dsk/c0d0s7 /dev/rdsk/c0d0s7 /export/home ufs 2 yes rq
rq mount options enables disk quota for /export/home. This make sure that disk quota enabled after each reboot.
Type the following command to mount /export/home with quota:
# mount -o remount,quota /export/home
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
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.
The quotaon command turns on disk quotas for /export/home ufs file systems. Type the command:
# quotaon -v /export/home
/export/home: quotas turned on
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
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
- For more information about quota, see the quota(1M), edquota(1M), repquota(1M), quotacheck(1M) and quotaon(1M) manpages.
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012
- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop