Solaris Disk Quotas
August 7, 2007 – 7:26 pmTip courtesy of Kyle Reynolds at http://www.camelrichard.org
Disk Quotas under Solaris
*************************
Create a quotas file (on root of filesystem):
———————————————
# /usr/bin/touch quotas
# /usr/bin/chmod 600 quotas
Display user’s quota on all mounted file systems where quotas exist:
——————————————————————-
# quota -v username
which will output something similar to this:
Disk quotas for user1 (uid 1175):
Filesystem usage quota limit timeleft files quota limit timeleft
/var/spool/mail 0 3072 5144 1 0 0
/home 1377 3072 5144 146 0 0
/tmp 0 1024 1024 0 0 0
Set or reset disk quota for users:
**********************************
Set disk quota for a user:
————————–
# /usr/sbin/edquota username
The editor invoked is vi unless the EDITOR environment variable specifies otherwise.
fs /acct/s1 blocks (soft = 0, hard = 0) \
inodes (soft = 0, hard = 0)
Modify it as below:
fs /acct/s1 blocks (soft = 95000, hard = 100000) \
inodes (soft = 9000, hard = 10000)
Save it and quit.
Set disk quota for all users:
—————————–
Create the following script to set disk quota for all users:
# vi .EQ
#!/bin/sh
LOGINS=`/usr/bin/ls | grep -v quotas | grep -v lost+found \
| grep -v csestudent`
for LOGIN in $LOGINS;
do
/usr/sbin/edquota -p csestudent $LOGIN
done
# /usr/bin/chmod 500 .EQ
# ./.EQ
Set soft time limit:
——————–
The soft time limits are initially set to the values defined for DQ_FTIMELIMIT and
DQ_BTIMELIMIT in /usr/include/sys/fs/ufs_quota.h. The default value is 7*24*60*60
– 1 week. It is fine for general use, otherwise enter:
# /usr/sbin/edquota -t
Turn quotas on:
***************
# vi /etc/init.d/quotaon
#!/bin/sh
/usr/sbin/quotacheck /path/to/filesystem
/usr/sbin/quotaon /path/to/filesystem
# /usr/bin/chmod 500 /etc/init.d/quotaon
# vi /etc/rc2.d/S99quota
#!/bin/sh
if [ -x /etc/init.d/quotaon ]; then
echo ‘Starting quota…’
/etc/init.d/quotaon &
fi
# /usr/bin/chmod 500 /etc/rc2.d/S99quota
# /etc/rc2.d/S99quota
Give warning to users:
**********************
Because no warning is given when the user has exceeded the soft limit, so add the
following to /etc/cshrc:
#
# check disk quota when users login
#
set groupline=`/usr/bin/groups`
if ($groupline[1] == student || $groupline[1] == students) then
/usr/sbin/quota -v
endif
unset groupline