Installing quotas in the kernel
===============================

The diffs found in the package are context diffs against plain 0.99pl14 code.
apply the patch with "patch -p1 < <whereever_you_put_it>/kernel_diffs" and wait
until patch has done it work. Then first check if all patches went right,
the you should find any *.rej files. If there are edit the files yourself
with the rejectionfile as a guideline on what to change. Then do a make
config and enable diskquotas.  Recompile your kernel and install the image.
That should do the trick no one should have a kernel with quotas in it.

Enabling quotas on a filesystem
===============================

To enable quotas on a certain filesystem one should edit the /etc/fstab
file and add entries for usrquota and grpquota. Mine looks like :

# device		directory	type	options				
/dev/hda1		/		ext2	defaults			
/dev/hda2		none		swap	sw
/dev/hda3 		/usr		ext2	defaults
/dev/hdb1 		/usr/users	ext2	defaults,usrquota,grpquota	
/dev/hdb2 		/usr/src	ext2	defaults,usrquota		
none			/proc		proc	defaults			

The keyword "usrquota" in the options field of each fstab-entry turns on
userquota for this device. The keyword "grpquota" in the options field turns
on groupquota for the device. When you use the usrquota and grpquota options
without the "=" option you quotafiles are located in the rootdir of each 
filesystem. A file called "quota.user" is used for userquota and a file called
"quota.group" is used for groupquota.

From version 1.1 you are also able to define your quotafile yourself there.
Something like "usrquota=/usr/adm/quotasrc.user". Please be aware of the
maximum lenght a line can have in your fstab, see mntent.h for a definition.

Turning quotas on
=================

When this is the first time you install quota run "quotacheck -avug" to
install all the quotafiles in the root dirs of your filesystems. Or when
you defined it with the [usr|grp]quota="" lines in your fstab in the place
you mention there. Don't use the -d flag of the quotacheck program when
checking a device because that is used for debugging purposes only and it
makes the scan very slowly.

The quotacheck program takes some time on large filesystems, but whith the
new version it is quite acceptable on my machine. But when you are hacking
the kernel, I recommend not to use it because it takes some time every time
you have to reboot your machine. You also can also put it in you rc script
and run it like you run fsck on your filesystems only when the fastreboot
flag is not set. There is no support for parallel checking of filesystems,
but maybe that will come in a next release. Please feel free to try
implement it. If nobody does it I have to do it myself but then it will
take some time because it is for now not very high on my wish list. And it
isn't probably to fast on an IDE disk to do simultaniously.

Ok now one should have all the quotafiles one needs.
Now you can add a line like:

/usr/etc/quotaon -avug (Or without the -v flag if you don't wanna see
                        what quota is being turned on).

to your /etc/rc. This is to turn the quotas on when you boot your machine.
This is they way to go and not turn it on yourself any time when you boot
your machine.

Checking a filesystem for quotas
================================

Just run "quotacheck -avug" and the quotafiles are updated automagicaly and
also the tables that are currently used by the kernel. Watch for the 
"updating in core quotas" message of the quotacheck program this says if it
updates the in core quotas in the kernel. I cannot state this enough the
quotafile is build as (uid || gid * sizeof(struct dquot)) so when you have
nonbody as uid 65535 and nobody owns a file you get big quota files, lets
say of about 2 Mb all filed with zero's for users that don't have quota.
So please be aware of that and don't mail me about that . It isn't
much of a problem only on startup the kernel needs some time to parse the
whole file. The in kernel needed dataspace is much smaller because only
users that have quota enabled are stored there and not all that haven't.
Specifing a quota for a user or group

Now use "edquota -u <username | uid>" to edit user quotas and "edquota
-g <groupname | gid>" to edit group quotas. Please pay atension that
groups under 10 don't have quotas and also uid under 10. You can change
this with ID_NO_QUOTA in the kernel headerfile (<linux/quota.h>).

Edit only the numbers behind the soft and hard keywords. There are two lines
for each filesystem that has quota turned on. Soft means the softlimit, if
people or groups go over there softlimit they have some grace period to make
sure they go under there softlimit.

This is something you can change with "edquota -t"  and enter the number of
days there. If they don't remove it within there graceperiod it is counted as
a hardlimit. The hardlimit is the absolute maximum they can allocate, if they
want more the files are truncated.

The one line that says blocks is the number of blocks one can allocate,
the line that says inodes is the number of inodes (files/named pipes/
devices/etc.) one can allocate.

Adding users all with the same quota
====================================

Go to the dir where there homedirs reside. Do a edquota for one of the users
and change the quotas to the approriate values. Then do this:

# edquota -p <the_user_you_edited with the correct values> `echo *`

this should do the trick, all users now have the quota they need, now
you could edit the ones that still need other values.

Checking quotas for a user
==========================

Run the quota program. The syntax for this program is :

Usage: quota [-guqv]
	quota [-qv] -u username ...
	quota [-qv] -g groupname ...

Use -v to see the quotas on 1) filesystems you don't have quotas on
                            2) filesystems on which you do have quota
                               but haven't allocated any blocks yet

Use -q to only see filesystems on which you are over you softlimit or
have reached your hardlimit.

The -g flags give you all quotas for the groups you are in (also
additional groups).

Disabling quota for a user
==========================

When you want to disable quotas for a certain user use the quota editor
edquota. Type "edquota <username | uid>" or "edquota -g <groupname | gid>"
and set block softlimit and hardlimit, and the inode soft- and hardlimit to 0.
This should disable the quota for that user an the user can allocate as many
blocks and inodes as he/she wants.

Listing of the quotas used by all users on a filesystem

To get a  listing of all quotas in use on a certain filesystem or on any
filesystem you use the repquota program. This program needs to read the
quotafiles so I needs to be run by the superuser, or by any user if you 
have your quotafiles readable by everyone, this is not recomended.

Quotas on NFS-mounted disks
===========================

To have quotas on NFS filesystems, you need to install quotas on the
fileserver and not on the client. Clients can obtain quota information
with the quota command which does a query to the rquotad running on the
fileserver from which you mount your NFS disks. So don't put any
usrquota or grpquota flags in the flags for mounting NFS disks. Instead
install quotas on your fileserver. And start the rpc.rquotad from your
network rc-file.

