Operating System - HP-UX
1752790 Members
6202 Online
108789 Solutions
New Discussion юеВ

how to set a quotum on a directory

 
E. Vodegel
Occasional Advisor

how to set a quotum on a directory

Hello,

I am working with a HP11.0 UNIX machine and I want to restrict the HOME-directory for users.

In a script I want to set a quotum of 10 MB on the /home/'username'-directory, so when the user passed this limit they get a notification (or something else).

Does somebody know how to get this in a script?

Bye,
Erwin
2 REPLIES 2
Steven Sim Kok Leong
Honored Contributor

Re: how to set a quotum on a directory

hi,

To enable quotas on /home:
=======================================
# touch /home/quotas
# vi /etc/fstab # add quota in the filesystem options
/dev/vg00/lvol11 /home hfs rw,suid,nolargefiles,quota 0 2
# quotaon /home # if you want the quotas to take effect now instead of reboot, alternatively un-mount and re-mount /home
# edquota username
=======================================

As for the script,
=======================================
#!/sbin/sh
cd /home
for user in *
do
usage=`quota -v |tail -1|awk '{print $2}' `
limit="10240"
if [ "$usage" -gt "$limit" ]
then
echo "You have exceeded the 10 MB quota!!! Please kindly trim your home directory." | write $user
fi
done
=======================================

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
Victor BERRIDGE
Honored Contributor

Re: how to set a quotum on a directory

Hi Erwin,
This is how I proceed:
1) Activate the quota file:
cpset /dev/null /home quotas 600 root bin
2) Create a model quota:
edquota berridge
This will invoke vi, that you will have to modify:
fs /home blocks (soft=0 hard=0) inodes (soft=0 hard=0 )
e.g.:
fs /users/ocpa blocks (soft = 10000, hard = 12000) inodes (soft = 260, hard = 320)

3) To use the quota just fixed for the users
edquota -p berridge

Good luck
Best regards
Victor