BSD Jails: Difference between revisions
From Leo's Notes
This page was last edited on 13 December 2012, at 06:50.
mNo edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
== Creating a new BSDJail == | |||
# mkdir -p /usr/jail/<jail name> | # mkdir -p /usr/jail/<jail name> | ||
| Line 9: | Line 8: | ||
# mount -t devfs devfs /usr/jail/<jail name>/dev | # 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 | 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 == | |||
add to /etc/ | To ensure the jail gets started on boot, add the following to your <code>/etc/rc.conf</code> 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 <code>/etc/jaials/fstabs/svn</code> | ||
/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 | |||
http://www.scottro.net/qnd/qnd-jail.html | jail# echo "enable_sshd=\"YES\"" >> /etc/rc.conf | ||
http://articles.slicehost.com/2007/9/5/introduction-to-svnserve | jail# /etc/rc.d/sshd start | ||
*http://www.scottro.net/qnd/qnd-jail.html | |||
*http://articles.slicehost.com/2007/9/5/introduction-to-svnserve | |||
Revision as of 06:50, 13 December 2012
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