fatworm
asked on
How to control mailbox's size?
My server use Redhat linux 6.0 + sendmail + imap4,and now I want to control the users's mailbox's size.
How can I do this?
How can I do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Quit rude perhaps, but you could enable quota's on the partition that holds /var/spool/mail. I don't know exactly, but I think the users new mail will be dropped when the quota limits are reached.
Well you could apply disk quotas to the filesystem that the mail spool is on, but every document I've ever seen on sendmail says that this is a "BAD IDEA". the problem is that the sendmail+imap4 doesn't check the space free before starting to accept a message. If that user runs out of quota while the message is being received bad things happen. Also there's no mechanism for notifying the user that their mailbox is at or near quota.
The Cyrus IMAP server implements a quota system for the mailboxes at a level that's compatible with the mail system. You can find out more about it and its quota system at: http://asg.web.cmu.edu/
The Cyrus IMAP server implements a quota system for the mailboxes at a level that's compatible with the mail system. You can find out more about it and its quota system at: http://asg.web.cmu.edu/
I don't know if there's a way to specifically limit mailbox size, but you can limit the total file space a user takes up (which would effectively limit mailbox size). the linux quota system limits disk space by user and group and by filesystem, so if your mailboxes were on their own filesystem you could limit just the users disk space for that filesystem. Here's the text from http://metalab.unc.edu/pub/Linux/docs/HOWTO/mini/Quota ::
4.3. Modify your system init script to check quota and turn
quota on at boot
Here's an example:
__________________________ __________ __________ __________ __________ ____
# Check quota and then turn quota on.
if [ -x /usr/sbin/quotacheck ]
then
echo "Checking quotas. This may take some time."
/usr/sbin/quotacheck -avug
echo " Done."
fi
if [ -x /usr/sbin/quotaon ]
then
echo "Turning on quota."
/usr/sbin/quotaon -avug
fi
__________________________ __________ __________ __________ __________ ____
The golden rule is that always turn quota on after your file systems
in /etc/fstab have been mounted, otherwise quota will fail to work. I
recommend turning quota on at the end of your system init script, or,
if you like, right after the part where file systems are mounted in
your system init script.
4.4. Modify /etc/fstab
Partitions that you have not yet enabled quota normally look something
like:
__________________________ __________ __________ __________ __________ ____
/dev/hda1 / ext2 defaults 1 1
/dev/hda2 /usr ext2 defaults 1 1
__________________________ __________ __________ __________ __________ ____
To enable user quota support on a file system, add "usrquota" to the
fourth field containing the word "defaults" (man fstab for details).
__________________________ __________ __________ __________ __________ ____
/dev/hda1 / ext2 defaults 1 1
/dev/hda2 /usr ext2 defaults,usrquota 1 1
__________________________ __________ __________ __________ __________ ____
Replace "usrquota" with "grpquota", should you need group quota
support on a file system.
__________________________ __________ __________ __________ __________ ____
/dev/hda1 / ext2 defaults 1 1
/dev/hda2 /usr ext2 defaults,grpquota 1 1
__________________________ __________ __________ __________ __________ ____
Need both user quota and group quota support on a file system?
__________________________ __________ __________ __________ __________ ____
/dev/hda1 / ext2 defaults 1 1
/dev/hda2 /usr ext2 defaults,usrquota,grpquota 1 1
__________________________ __________ __________ __________ __________ ____
4.5. Create quota record "quota.user" and "quota.group"
Both quota record files, quota.user and quota.group, should be owned
by root, and read-write permission for root and none for anybody else.
Login as root. Go to the root of the partition you wish to enable
quota, then create quota.user and quota.group by doing:
__________________________ __________ __________ __________ __________ ____
touch /partition/quota.user
touch /partition/quota.group
chmod 600 /partition/quota.user
chmod 600 /partition/quota.group
__________________________ __________ __________ __________ __________ ____
4.6. Reboot
Now reboot system for the changes you have made to take effect.
Also note that subsequent partitions you wish to enable quota in the
future only require step 4, 5, and 6.
5. Quota Setup on Linux - Part II: Assigning Quota for Users and
Groups
This operation is performed with the edquota command (man edquota for
details).
I would normally run quotacheck with the flags -avug to obtain the
most updated filesystems usage prior to editing quota. This is just a
personal habit, and not a required step however.
5.1. Assigning quota for a particular user
Here's an example. I have a user with the login id bob on my system.
The command "edquota -u bob" takes me into vi (or editor specified in
my $EDITOR environment variable) to edit quota for user bob on each
partition that has quota enabled:
__________________________ __________ __________ __________ __________ ____
Quotas for user bob:
/dev/hda2: blocks in use: 2594, limits (soft = 5000, hard = 6500)
inodes in use: 356, limits (soft = 1000, hard = 1500)
__________________________ __________ __________ __________ __________ ____
"blocks in use" is the total number of blocks (in kilobytes) a user
has comsumed on a partition.
"inodes in use" is the total number of files a user has on a
partition.
4.3. Modify your system init script to check quota and turn
quota on at boot
Here's an example:
__________________________
# Check quota and then turn quota on.
if [ -x /usr/sbin/quotacheck ]
then
echo "Checking quotas. This may take some time."
/usr/sbin/quotacheck -avug
echo " Done."
fi
if [ -x /usr/sbin/quotaon ]
then
echo "Turning on quota."
/usr/sbin/quotaon -avug
fi
__________________________
The golden rule is that always turn quota on after your file systems
in /etc/fstab have been mounted, otherwise quota will fail to work. I
recommend turning quota on at the end of your system init script, or,
if you like, right after the part where file systems are mounted in
your system init script.
4.4. Modify /etc/fstab
Partitions that you have not yet enabled quota normally look something
like:
__________________________
/dev/hda1 / ext2 defaults 1 1
/dev/hda2 /usr ext2 defaults 1 1
__________________________
To enable user quota support on a file system, add "usrquota" to the
fourth field containing the word "defaults" (man fstab for details).
__________________________
/dev/hda1 / ext2 defaults 1 1
/dev/hda2 /usr ext2 defaults,usrquota 1 1
__________________________
Replace "usrquota" with "grpquota", should you need group quota
support on a file system.
__________________________
/dev/hda1 / ext2 defaults 1 1
/dev/hda2 /usr ext2 defaults,grpquota 1 1
__________________________
Need both user quota and group quota support on a file system?
__________________________
/dev/hda1 / ext2 defaults 1 1
/dev/hda2 /usr ext2 defaults,usrquota,grpquota
__________________________
4.5. Create quota record "quota.user" and "quota.group"
Both quota record files, quota.user and quota.group, should be owned
by root, and read-write permission for root and none for anybody else.
Login as root. Go to the root of the partition you wish to enable
quota, then create quota.user and quota.group by doing:
__________________________
touch /partition/quota.user
touch /partition/quota.group
chmod 600 /partition/quota.user
chmod 600 /partition/quota.group
__________________________
4.6. Reboot
Now reboot system for the changes you have made to take effect.
Also note that subsequent partitions you wish to enable quota in the
future only require step 4, 5, and 6.
5. Quota Setup on Linux - Part II: Assigning Quota for Users and
Groups
This operation is performed with the edquota command (man edquota for
details).
I would normally run quotacheck with the flags -avug to obtain the
most updated filesystems usage prior to editing quota. This is just a
personal habit, and not a required step however.
5.1. Assigning quota for a particular user
Here's an example. I have a user with the login id bob on my system.
The command "edquota -u bob" takes me into vi (or editor specified in
my $EDITOR environment variable) to edit quota for user bob on each
partition that has quota enabled:
__________________________
Quotas for user bob:
/dev/hda2: blocks in use: 2594, limits (soft = 5000, hard = 6500)
inodes in use: 356, limits (soft = 1000, hard = 1500)
__________________________
"blocks in use" is the total number of blocks (in kilobytes) a user
has comsumed on a partition.
"inodes in use" is the total number of files a user has on a
partition.
I agree with jlevie, thats a cleaner solution. But since he said "RH6.0" i figured he wanted to stick with the "tsandard tools" Since cyrus only supports quota if you switch from unix-format to their own mbox format, which means that (for instance) Pine will not be a happy camper. But it is a better solution in the long run.