Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Jun 2003 21:31:15 -0600 (CST)
From:      Ryan Thompson <ryan@sasknow.com>
To:        Josh Brooks <user@mail.econolodgetulsa.com>
Cc:        questions@freebsd.org
Subject:   Re: question regarding quotas
Message-ID:  <20030629210853.T86432-100000@ren.sasknow.com>
In-Reply-To: <20030629180934.O57224-100000@mail.econolodgetulsa.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Josh Brooks wrote to Lowell Gilbert:

> Again, I am just trying to take an arbitrary directory, say:
>
> /export/data7/homes/jerry
>
> and place a configurable limit on how big that directory can get,
> without mounting it as its own filesystem...

FreeBSD doesn't support any filesystems that do this proactively. From
an OS point of view, it doesn't really make sense. However, I can see a
few scenarios where this would be helpful, and it is more than possible
to enforce directory size limits reactively. For example:

#!/bin/sh

if [ $# -ne 1 ]; then
    echo "usage: $0 pathname" 1>&2
    exit 2
fi

QUOTA="102400";	    # Max. usage, kilobytes
SIZE=`du -xd 0 $1 | cut -f 1`
echo "Directory size is $SIZE"

if [ $SIZE -gt $QUOTA ]; then
    echo "$1 is over quota";	# Take appropriate action, here...
else
    echo "$1 is OK";
fi

That's an illustrative example; it'll be easy to extend that to loop
over an arbitrary list of users (or all system users). You can then run
it periodically from cron(8) to check disk usage at the interval of your
choosing, and react accordingly.

As others have mentioned, users may find other directories and
filesystems to store files, thereby circumventing your quota check. So,
it's up to you to harden your system to mitigate that. Also, as this is
a reactive approach, your users still have the ability to fill up your
disk, but at least you can react appropriately (and possibly
automatically). Though, I think I've at least answered your question.
:-)

Hope this helps,
- Ryan

-- 
  Ryan Thompson <ryan@sasknow.com>

  SaskNow Technologies - http://www.sasknow.com
  901-1st Avenue North - Saskatoon, SK - S7K 1Y4

        Tel: 306-664-3600   Fax: 306-244-7037   Saskatoon
  Toll-Free: 877-727-5669     (877-SASKNOW)     North America




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030629210853.T86432-100000>