Sunday, February 15, 2009

Using Ports within a jail

To cut down on hard drive space use it's a good idea to use the ports directory from the main system in each jail. To secure it the best idea is to mount /usr/ports read only. The problem with having /usr/ports read only is the source can not be saved in /usr/ports/distfiles. To fix this we need to tell make to save the files elsewhere.

First edit /etc/fstab and add
/usr/ports/PATH_TO_JAIL     /usr/ports     nullfs     ro     0     0

After remount file systems
mount -a

From within the jail create the dir /var/distfile and add
DISTDIR=/var/distfile and WRKDIRPREFIX=/var/distfiles to /etc/make.conf

All the files shoud besave in /var/distfile from now on.