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:
Need to tidy this up later.
== 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  


To start the jail manually, you can...
== 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
-n specifies the name
then you provide the path, hostname, IP, and the shell


Note that this is a one-time thing. If you want it persistent, continue reading on...


jail_enable="YES"
== Starting Jails Automatically ==
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
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"


/usr/src        /usr/jail/svn/usr/src  nullfs  rw      0 0
Add to <code>/etc/jaials/fstabs/svn</code>
/usr/ports      /usr/jail/svn/usr/ports nullfs  rw      0 0


/usr/src        /usr/jail/svn/usr/src  nullfs  rw      0 0
/usr/ports      /usr/jail/svn/usr/ports nullfs  rw      0 0


/etc/rc.d/jail start svn
Start the jail using the rc scripts


jls  #get the jid
/etc/rc.d/jail start svn
jexec <jid> sh


jail# echo "enable_sshd=\"YES\"" >> /etc/rc.conf
== Managing Jails ==
jail# /etc/rc.d/sshd start


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

  1. mkdir -p /usr/jail/<jail name>
  2. cd /usr/src
  3. make buildworld
  4. make installworld DESTDIR=/usr/jail/<jail name>
  5. make distribution DESTDIR=/usr/jail/<jail name>
  6. 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