FreeBSD - In-Jail Quota System


2005-02-16

First, create the jail. The jail should have it’s own partition otherwise UIDs and GIDs will clash with other jails and the host machine.

Host Configuration

Compile quota support into the host machine’s kernel (it is not necesarry to compile quota support into the jail).

Assuming you already have a jail on it’s own partition, and a df -h output would look like this:

/dev/md13c     1.9G    692M    1.1G    38%    /data/jails/10.0.0.2

Do the following on the HOST computer:

# vi /etc/fstab
/dev/md13c /data/jails/10.0.0.2 ufs rw,userquota,groupquota 2 2

I am not sure if this is necesarry but I have always done a stop and start the jail to remount the partition.

# jail_stop 10.0.0.2
# jail_start 10.0.0.2

Now the only thing left to do on the host machine is activate quota support for the jail’s partition.

# quotaon /data/jails/10.0.0.2

Jail Configuration

Login to the Jail as root and add quota support to the root partition.

# vi /etc/fstab
/dev/md13c   / ufs rw,userquota,groupquota 2 2

The quotacheck command must be run once to create the quota.user and quota.group files, and those files need to be made world readable.

# quotacheck /
# cd /
# chmod 644 quota.user
# chmod 644 quota.group

From now on quotas will work but you need to remember to run the quotaon command from the host machine every time the jail is restarted.