Create a Jail: Difference between revisions
From HateotU
(Created page with "==Create a Jail== Replace <jailname> with the Name of your Jail ===If you're using zfs, every jail should have it's own zfs pool=== * Create a new zfs pool zfs create zfs0/<j...") |
No edit summary |
||
Line 11: | Line 11: | ||
mkdir /export/jails/<jailname> | mkdir /export/jails/<jailname> | ||
===Now, you can install the Jail=== | ===Now, you can install the Jail=== | ||
/export/jails/ | cd /export/jails/ | ||
bsdinstall jail <jailname>/ | bsdinstall jail <jailname>/ | ||
*Follow the steps on the screen until the installation is finished | |||
===It's time to edit /etc/jail.conf=== | ===It's time to edit /etc/jail.conf=== | ||
vi /etc/jail.conf | vi /etc/jail.conf | ||
Line 35: | Line 36: | ||
allow.sysvipc = 0; | allow.sysvipc = 0; | ||
path = "/export/jails/${name}"; | path = "/export/jails/${name}"; | ||
<jailname> { | <jailname> { | ||
host.hostname = "<jailname>.hateotu.de"; | host.hostname = "<jailname>.hateotu.de"; | ||
ip4.addr = <ip the new Jail should have>; | ip4.addr = <ip the new Jail should have>; | ||
} | } | ||
*If the Jail needs special options to be set, you should enter them into the section of the Jail under the IP Adress: | |||
<jailname> { | |||
host.hostname = "<jailname>.hateotu.de"; | |||
ip4.addr = <ip the new Jail should have>; | |||
<option> = <value> | |||
} | |||
===Create the fstab file for the new Jail=== | |||
touch /etc/fstab.<jailname> | |||
===Now, you can start the new Jail=== | |||
service jail start <jailname> | |||
*To open a shell on your Jail, type: | |||
jexec <jailname> <shell> |
Revision as of 12:57, 13 August 2016
Create a Jail
Replace <jailname> with the Name of your Jail
If you're using zfs, every jail should have it's own zfs pool
- Create a new zfs pool
zfs create zfs0/<jailname>
- Set the mountpoint option for the new zfs pool
zfs set mountpoint=/export/jails/<jailname> zfs0/<jailname>
- Mount the new Pool
zfs mount -a
If you're not using zfs, you should create a new folder for the Jail in /export/jails
mkdir /export/jails/<jailname>
Now, you can install the Jail
cd /export/jails/ bsdinstall jail <jailname>/
- Follow the steps on the screen until the installation is finished
It's time to edit /etc/jail.conf
vi /etc/jail.conf
- If there are already Jails installed at the host, create a new section for your Jail at the End of the file
<jailname> { host.hostname = "<jailname>.hateotu.de"; ip4.addr = <ip the new Jail should have>; }
- If there are no Jails installed, and so, the file is empty, paste the following content into the file
allow.raw_sockets = 0; exec.clean; exec.system_user = "root"; exec.jail_user = "root"; exec.start += "/bin/sh /etc/rc"; exec.stop = "/bin/sh /etc/rc.shutdown"; exec.consolelog = "/var/log/jail_${name}_console.log"; interface="bge0"; mount.devfs; mount.fstab = "/etc/fstab.$name"; allow.mount; allow.set_hostname = 0; allow.sysvipc = 0; path = "/export/jails/${name}"; <jailname> { host.hostname = "<jailname>.hateotu.de"; ip4.addr = <ip the new Jail should have>; }
- If the Jail needs special options to be set, you should enter them into the section of the Jail under the IP Adress:
<jailname> { host.hostname = "<jailname>.hateotu.de"; ip4.addr = <ip the new Jail should have>; <option> = <value> }
Create the fstab file for the new Jail
touch /etc/fstab.<jailname>
Now, you can start the new Jail
service jail start <jailname>
- To open a shell on your Jail, type:
jexec <jailname> <shell>