Virtualmin and Quotas

Tags:

Loaded Virtualmin onto a Linode running Centos 6. Ran into some errors when trying to add a domain:

Failed to create virtual server : setquota: Cannot stat() mounted device /dev/root: No such file or directory setquota: Mountpoint (or device) / not found or has no quota enabled. setquota: Not all specified mountpoints are using quota.

And indeed, from a root prompt:

# <strong>quotaon -p -a</strong>
quotaon: Cannot stat() mounted device /dev/root: No such file or directory
group quota on /home (/dev/xvdc) is off
user quota on /home (/dev/xvdc) is off

Hmm, yep, that's the same error. This thread on Virtualmin's forum was a big clue, here's the first step to resolution:

# <strong>mount</strong>
...
/dev/xvda on / type ext3 (rw,noatime,grpquota,errors=remount-ro,usrquota)
...

Right, so our root / partition is indeed on /dev/xvda so we can create the missing symbolic link:

# <strong>ln -s /dev/xvda /dev/root</strong>
# <strong>quotaon -a</strong>
quotaon: cannot find /home/aquota.group on /dev/xvdc [/home]
quotaon: cannot find /home/aquota.user on /dev/xvdc [/home]
#

Good, no error message. But things are still not working yet:

# <strong>quotaon /home</strong>
quotaon: cannot find /home/aquota.group on /dev/xvdc [/home]
quotaon: cannot find /home/aquota.user on /dev/xvdc [/home]

Before proceeding, in /etc/fstab please be sure "usrquota" and "grpquota" are in the options line:

/dev/xvdc  /home  ext3  grpquota,errors=remount-ro,usrquota,grpquota,noatime,rw  0  1

Now, instead of going thru a dozen cryptic commands, go back to Webmin (if Virtualmin is up, click Webmin on the top line). Open the System tab and then Disk Quotas. You should see the /home partition listed, and it probably says that quotas are not active. Simply hit "Enable Quotas" and the display should change to:

*Filesystem *

*Type *

*Mounted From *

*Status *

*Action *

/home (users) /home (groups)

Linux Native Filesystem

Xen device C

User and Group Quotas Active

Disable Quotas

...Done!

Hosting Quotas Gotcha

Tags:

I am really liking Virtualmin, but just got bitten, hard, by an unexplained problem. Postfix started rejecting incoming mail, saying in the logfile (/var/log/maillog)

status=bounced (can't create user output file)

Well after much gnashing of teeth, it turns out that the user (me) was over quota. You can see this with:

# quota itsme.mydomain
Disk quotas for user itsme.mydomain (uid 536):
     Filesystem  blocks   quota   limit   grace   files   quota   limit   grace
      /dev/xvda   51200   51200   51200              73       0       0

Hmm... where are those extra files? Not anywhere in /home ... read on --Turns out, if you leave the "Scan for viruses?" checked (under "Enabled Features" on the "Edit Virtual Server" tab) then clamav will scan incoming email for viruses... and nearly instantly kill your default 50MB per-user quota... and this is nearly impossible to find, but go look in /tmp and you'll find /tmp/clamav-somebignumber as a directory with files (main.db, main.hdb, main.info, main.mdb, main.ndb) and they will be, oh, 15 megabytes in size. Ugh. Disable virus scanning and delete those files. Or else push your users' quotas up by maybe 100MB for the per-user virus databases.

Maybe there's a way to have clamav keep a system-wide virus database instead. That would be much more logical, it seems. Or how about leaving that up to users.

I still haven't found where to make "Scan for viruses" off by default for new domains.

You might also want to check the users' mail inboxes, which are located at:

/home/domain/homes/username/Maildir

where domain is the username for the domain, and username is the user's name inside the domain. You will recognize these because the POP or IMAP login for that user is domain.username.