Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Disk Quota

Posted on 2003-03-11
Medium Priority
Last Modified: 2013-12-27

   I just search to limit user email account on my qmail server.  My server is a sparc with sunOS 5.9. I read something about disk quota but i didn't know how to set up the quota ! Does antone know how to set up quota ??


Question by:jaubm

Accepted Solution

SumeshDaftary earned 1000 total points
ID: 8111778
The quota system (available only on ufs and vxfs filesystems) is built around limits on the two principal resources of a filesystem:

data blocks

For each of these resources, users can be assigned quotas.
Two limits can be used: hard limit and soft limit. The hard limit represents an absolute limit on the resource. Associated with the soft limit is a time limit set by the administrator. Users can exceed the soft limits for a limited amount of time.

In summary, for each user, you can assign quotas (soft and hard limits) for both blocks and inodes. Also a time limit can be set indicating how long users can exceed the soft limits.

Remember: only super-user (root) can set disk quota.

Create a quotas file
The filesystem is /acct/s1. If quotas is already there, goto the next step.
# su -
# cd /acct/s1
# /usr/bin/touch quotas
# /usr/bin/chmod 600 quotas

Set or reset disk quota for users
Assume each student has 100MB (102400KB, we use 100000KB here) disk quota and when he uses 95MB, we need remind him that he reaches his limit. Also a student cannot create more than 10000 files (including directoies) and the soft limit is 9000. So the hard data block limit is 100000, the soft data block limit is 95000; the hard inode limit is 10000, the soft inode limit is 9000.

Set disk quota for a proto-user
Select a proto-user name. For example, csestudent.

# /usr/sbin/edquota csestudent
The editor invoked is vi unless the EDITOR environment variable specifiles 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
   LOGINS=`/usr/bin/ls | grep -v quotas | grep -v lost+found \
           | grep -v csestudent`
   for LOGIN in $LOGINS;
       /usr/sbin/edquota -p csestudent $LOGIN
# /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
  /usr/sbin/quotacheck /acct/s1
  /usr/sbin/quotaon /acct/s1            
# /usr/bin/chmod 500 /etc/init.d/quotaon
# vi /etc/rc2.d/S99quota
  if [ -x /etc/init.d/quotaon ]; then
      echo 'Starting quota...'
      /etc/init.d/quotaon &
# /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
unset groupline

LVL 18

Expert Comment

ID: 10475145
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

Answered by  SumeshDaftary

Please leave any comments here within the next four days.


EE Cleanup Volunteer

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question