BSD Jails
From Leo's Notes
This page was last edited on 13 December 2012, at 06:50.
Creating a new BSDJail
- mkdir -p /usr/jail/<jail name>
- cd /usr/src
- make buildworld
- make installworld DESTDIR=/usr/jail/<jail name>
- make distribution DESTDIR=/usr/jail/<jail name>
- mount -t devfs devfs /usr/jail/<jail name>/dev
Starting a Jail Manually
jail -n <jail name> /usr/jail/<jail name> <jail name> 10.1.1.20 /bin/sh
Note that this is a one-time thing. If you want it persistent, continue reading on...
Starting Jails Automatically
To ensure the jail gets started on boot, add the following to your /etc/rc.conf file
jail_enable="YES" jail_svn_name="svn" jail_svn_hostname="svn.home.steamr.com" jail_svn_ip="10.1.1.20" jail_svn_devfs_enable="YES" jail_svn_rootdir="/usr/jail/svn" jail_svn_mount_enable="YES" jail_svn_fstab="/etc/jails/fstabs/svn" jail_svn_vnet_enable="YES"
Add to /etc/jaials/fstabs/svn
/usr/src /usr/jail/svn/usr/src nullfs rw 0 0 /usr/ports /usr/jail/svn/usr/ports nullfs rw 0 0
Start the jail using the rc scripts
/etc/rc.d/jail start svn
Managing Jails
jls #get the jid jexec <jid> sh
jail# echo "enable_sshd=\"YES\"" >> /etc/rc.conf jail# /etc/rc.d/sshd start