ل Personalلل|لل Privateلل|لل Researchلل|لل Workلل|لل Bookmarksلل|لل Searchلل|لل
homeلل >> لل work لل >> لل systemadmin

Set disk quota on Solaris 7


The quota system (available only on ufs and vxfs filesystems) is built around limits on the two principal resources of a filesystem:

  • inodes
  • 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 -
    passwd:
    # 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.

    1. 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.

    2. 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

    3. 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 /acct/s1
      /usr/sbin/quotaon /acct/s1            
    # /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


Last Modified: Thu May 03 00:07:23 2001
¨2001 Jicheng Qu Homepage . All rights reserved.
URL: http://www.cse.sc.edu/~jqu/work/systemadmin/diskquota.html