Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 22 Sep 2002 12:43:57 +0100
From:      Matthew Seaman <m.seaman@infracaninophile.co.uk>
To:        Ihsan Junaidi Ibrahim <ihsan_junaidi@yahoo.com.sg>
Cc:        freebsd-questions@FreeBSD.ORG
Subject:   Re: Quota problem
Message-ID:  <20020922114357.GA5420@happy-idiot-talk.infracaninophi>
In-Reply-To: <10155447689.20020922150102@yahoo.com.sg>
References:  <5135932470.20020919122234@yahoo.com.sg> <3399860291.20020921211848@yahoo.com.sg> <10155447689.20020922150102@yahoo.com.sg>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, Sep 22, 2002 at 03:01:02PM +0800, Ihsan Junaidi Ibrahim wrote:

 
> Well I've narrowed down the problem towards disk quotas. It turns
> out that when I disable quotas, everything works fine. When I first
> setup quotas on /home, I did not place any quota on the user nor
> group, with the intention of placing for one later. I think I know
> the specific problems but I'm not that sure.

OK.  Here's a brief rundown of what you need to do to get filesystem
quotas working.

    i) Read through these man pages:

        quota(1)
        edquota(8)
        quotacheck(8)
        quotaon(8)
        repquota(8)
        fstab(5)

       Additionally, any of the other pages turned up by 'man -k quota' 

   ii) Prepare your system.  You need to add 'options QUOTA' to your
       kernel config and compile yourself a new kernel, or the system
       simply won't support quotas.

  iii) Add:

        enable_quotas="YES"
        check_quotas="YES"

       to /etc/rc.conf.  Now, when you reboot into your new kernel you
       would see 

        Checking quotas : done
        Enabling quotas : done

       printed on the console.  You don't need to reboot just yet
       though.

   iv) At this point no filesystems have been marked as using quotas.
       I'm going to use my /var partition as an example.

       Edit /etc/fstab to enable quotas on the partition.  As I don't
       want the quota files cluttering up the root of the filesystem,
       I'm going to move them into a subdirectory.

        /dev/da0s1e             /var            ufs     rw,userquota=/var/quota/var.user,groupquota=/var/quota/var.group              2       2

       Create the /var/quota directory, and generate baseline quota
       files.  quotacheck(8) should be run when the filesystem is
       quiescent for best results:

        mkdir /var/quota
        quotacheck -v /var
       
       Now, set up the per-uid or per-group limits with edquota(8)

        edquota -f /var username

       If you've got lots of users, set up one with default values and
       use 'edquota -p defaultuser 1000-2000' to copy the settings to
       a range of UIDs in one go.

       All of the above can be done without having quotas enabled in
       the kernel yet (although you will see many warning messages to
       that effect).

    v) Turn on quotas on the partition.  If you had to modify the
       kernel in step ii), then you've got to reboot at this point.
       Otherwise you can just run:

        quotaon -v /var

   vi) Check that everything seems to be working by running
       repquota(8) and quota(1).  Try adding some big files and
       testing that quota limits are enforced.

Repeat as necessary for other filesystems.  That's all there is to it.

> 1) Does file/dir ownership of another user counts? I have a single
> directory with files with someone else ownership.

The quota system keeps track of the ownership of every entity created
on the file system, be it a plain file, a directory or some other
thing.  It keeps track of the changes in the number of bytes and the
number of inodes used by each UID by having hooks into the system
calls (like open(2), truncate(2), write(2), etc) that can create or
destroy files or change their size.  The quotacheck(8) command should
be used to establish a baseline when setting up quotas for the first
time, and on reboot (check_quotas="YES" in /etc/rc.conf) to ensure
sanity.

The quota system will add a small amount of overhead to file IO on the
partition, but for normal usage for shell accounts and the like it's
not significant.  

> 2) Does quotas have problem with this kind of thing?

No.  It doesn't matter if a directory contains files owned by any
number of different users, or if a users' files are scattered all over
the partition.  It doesn't matter either if you've only specified
quota limits for some of your users --- the rest will default to
having an unlimited quota.

> 3) I ran file quota.user and the output says it's a text file
> without line terminators but when I did less on it, all I got is a
> repetitive sequence of '@@@' character. When I tried to edit it, all
> I got is a blank screen. Is this a sign of the
> quota.user/quota.group is corrupted?

No --- the quota.user file consists of a list of fixed size records,
and uses the UID of the user as an index into the file to locate the
data for that user.  (Similarly, it uses the GID in the quota.group
file).  That means that if you have, say, a /home partition and you
are the only user with any files on the partition and your user id is
1000, then the quota.user file will consist of 1001 records, most of
which will be unused and empty.  The unused stuff is usually filled
with ascii NULL characters, often represented as '^@' when viewing a
file.

Of course, it's most unusual for root not to own any files at all on a
partition, so there should be some interesting data right at the
beginning of the file (record 0).  The fact that you're not seeing
anything suggests that your quota.user file hasn't been properly
initialized.  Once there's something more that NULLs in there, file(1)
will report the type as 'data'.

[As an aside, once, long long ago, I had a bunch of NeXT boxes NFS
mounting files from a BSD 2.2.x server.  The NeXT machines had a
'nobody' UID specified as -1 --- fine on a NeXT box, where the uid_t
was a short int and that evaluated to a uid of 65535.  However on the
FreeBSD file server, uid_t was a 32bit unsigned and that UID was
effectively 4294967295.  That's a very big quota.user file...]

	Cheers,

	Matthew

-- 
Dr Matthew J Seaman MA, D.Phil.                       26 The Paddocks
                                                      Savill Way
                                                      Marlow
Tel: +44 1628 476614                                  Bucks., SL7 1TH UK

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




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