Email Disk Usage Quota

Yeah, okay, so I want to get disk quotas working on the mail spool filesystem, because I'm getting tired of users filling up our disk with spam. We need to purge our system of dead accounts, but in general, this is a good policy.

  1. Compile quota support into the kernel
  2. add enable_quotas="YES" to /etc/rc.conf
  3. Add the userquota option in /etc/fstab for the filesystem in question
  4. Modify the mailer definition of
  5. Add a -S option to qpopper
  6. Reboot (or run quotacheck and quotaon for the filesystem)
  7. use edquota to set quotas for users

Kernel Support

Disk quotas are enforced by the kernel, but by default this support is not enabled in the kernel. You need to add the following option to the kernel config and recompile:

	options		QUOTA			#enable disk quotas

Sendmail Mailer Definition

Okay, two things have to be added to the mailer definition. This starts with the line in /etc/mail/ that begins with "Mlocal". First, you need to add the 'o' flag to the mailer definition. The flags are defined where it says F=..., and you can add the 'o' anywhere on the line. Then, you need to add a -b option to the mail.local command line, which is defined where it says A=...

Don't forget to restart sendmail.

What Now?

Well, I got disk quotas working, although I had a little trouble with it. As in, I hung my machine. It all worked the second time around, but that was after running quotacheck and quotaon for the filesystem. I'll have to reboot again to see if it stays working. If so, that might indicate that you have to run quotacheck once when setting up disk quotas for a filesystem.

However, and this is the point I got to last time, disk quotas aren't solving my problem. You see, sendmail runs as root (most of the time). Thus, it is not subject to the specific user's disk quota. How do I fix that?

Hmm, I'll bet there is a flag for the mailer definition.

Missing Quota?

I set up disk quotas, and they seemed to work great. At that point, I stopped paying attention to disk utilization on the mail server. Several months later, we had a problem with the disk filling up again. I found a bunch of oversized mailboxes and discovered that many users on the system didn't have disk quotas anymore.

I haven't figured out what caused this. I did go and apply disk quotas again to all of those accounts, and I will keep an eye on it. I'm not quite sure how the quota could have been undone.