User Quotas

Our control panel restricts disk usage by resource (e.g. a user login or database).

Databases

For databases, we simply use du to check database usage via a cron job and, if a database has gone over, we disable each database user with write access to that database.

Users

For email and web site disk usage, we use the ext4 quota sytem to set a quota and depend on it to inform users when they have gone over.

Enabling quotas

quotas are enabled automatically by the sower --live generate:fstab command when operating on a weborigin or mailstore server.

This script takes the following steps:

  1. Ensures that the line for the partition in /etc/fstab sets the mount options to: defaults,usrjquota=aquota.user,jqfmt=vfsv1,nosuid,nodev
  2. Ensures quota package is installed
  3. Turns on the ext4 internal quota system with: tune2fs -O quota /path/to/device
  4. Mounts the partition
  5. This step is now deprecated and is no longer run: If the aquota.user file is absent, runs quotacheck -cum /path (we don’t need an aquota.user file any more because the tune2fs command records that information within the filesystem metadata).
  6. Runs quotaon --user -p /path and if it is successful, runs quotaon /path (if not successful, it means it’s already on)

Keeping it all in sync

A cron job runs on every server with quota (/usr/local/share/red/node/sbin/update-disk-usage) that checks disk usage and copies it back to the contorl panel.