This is the old XigmaNAS forum in read only mode,
it will taken offline by the end of march 2021!



I like to aks Users and Admins to rewrite/take over important post from here into the new fresh main forum!
Its not possible for us to export from here and import it to the main forum!

[HowTo] Setup Jail made simple

Jails with XigmaNAS
Forum rules
Set-Up GuideFAQsForum Rules
Post Reply
User avatar
dech
Starter
Starter
Posts: 20
Joined: 10 Apr 2013 19:48
Status: Offline

[HowTo] Setup Jail made simple

Post by dech »

Moin,
Since many people ask me on how to simplify the Setupprocess of a jail I have a few hints.

Code: Select all


Do what you whant.
Don't blame me if something f_* up.

# zfs create -o mountpoint=/jails zm/jails

# mkdir /jails/files
# mkdir /jails/proto

# cd /jails/files
# fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/`uname -m`/`uname -m`/`uname -r | cut -d- -f1-2`/base.txz


# cd /jails/files
# tar xvf base.txz -C /jails/proto
# cp /etc/resolv.conf /jails/proto/etc/

# jail -c path=/jails/proto \
name=proto \
host.hostname=proto.fantaranch.tld \
ip4.addr=192.168.1.112 \
interface=bge0 \
mount.devfs \
persist

see man jail for additional settings like mounting drives.
http://www.freebsd.org/cgi/man.cgi?query=jail&manpath=FreeBSD+9.1-RELEASE

# jls
JID  IP Address      Hostname                      Path
     1  192.168.1.112   proto.fantaranch.tld          /jails/proto

# jexec proto hostname
proto.fantaranch.tld

Autostart of "proto" jail

Open WebUI

- System|Advanced|Command scripts
- Add Command with "+" 
Command = /usr/sbin/jail -c path=/jails/proto name=proto host.hostname=proto.fantaranch.tld ip4.addr=192.168.1.112 interface=bge0 mount.devfs persist
Type = PostInit

User avatar
alexey123
Moderator
Moderator
Posts: 1469
Joined: 19 Aug 2012 08:22
Location: Israel, Karmiel
Contact:
Status: Offline

Re: [HowTo] Setup Jail made simple

Post by alexey123 »

1. TheBrig extension have NAS4Free webgui for build and control jails more simple
2. Build jails on folder /jail (only one step from root) is not good idea. This way not will work stable. For example original Freebsd jail environment have path /usr/jail - 2 step from root.
Home12.1.0.4 - Ingva (revision 7091)/ x64-embedded on AMD A8-7600 Radeon R7 A88XM-PLUS/ 16G RAM / UPS Ippon Back Power Pro 600
Lab 12.1.0.4 - Ingva (revision 7091) /x64-embedded on Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz / H61M-DS2 / 4G RAM / UPS Ippon Back Power Pro 600

User avatar
dech
Starter
Starter
Posts: 20
Joined: 10 Apr 2013 19:48
Status: Offline

Re: [HowTo] Setup Jail made simple

Post by dech »

Moin,
1. Using a UI is just a matter of personal flavour.
1.1 Personally I like "The Warden" or ezjail. With the warden its also much more simple to jail a debian linux.
2. orginal FreeBSD has no default path. Please explain why it would not work stable? Using it since years this way.

dech

User avatar
raulfg3
Site Admin
Site Admin
Posts: 4865
Joined: 22 Jun 2012 22:13
Location: Madrid (ESPAÑA)
Contact:
Status: Offline

Re: [HowTo] Setup Jail made simple

Post by raulfg3 »

please , no jails wars here, both aproach are valid, one is better for power user that know what do ( dech ) and other is desinged to facilitate life to non power users (thebrig) alexey.
12.1.0.4 - Ingva (revision 7743) on SUPERMICRO X8SIL-F 8GB of ECC RAM, 11x3TB disk in 1 vdev = Vpool = 32TB Raw size , so 29TB usable size (I Have other NAS as Backup)

Wiki
Last changes

HP T510

User avatar
dech
Starter
Starter
Posts: 20
Joined: 10 Apr 2013 19:48
Status: Offline

Re: [HowTo] Setup Jail made simple

Post by dech »

Moin,
:) thats no jail war. I just like to know why using /jails as the root for the jails is bad idea.
Also the tool you use for creating jails is just a matter of personal flavour.

dech

User avatar
alexey123
Moderator
Moderator
Posts: 1469
Joined: 19 Aug 2012 08:22
Location: Israel, Karmiel
Contact:
Status: Offline

Re: [HowTo] Setup Jail made simple

Post by alexey123 »

dech wrote:Moin,
1. Using a UI is just a matter of personal flavour.
1.1 Personally I like "The Warden" or ezjail. With the warden its also much more simple to jail a debian linux.
TheBrig have some functions as webmin module for jail. You can create and manage jails with webgui, your config stored into nas4free config.xml - so if you have zero problem with upgrade parent system.
2. orginal FreeBSD has no default path. Please explain why it would not work stable? Using it since years this way.
Because Freebsd security limits - sysctl security.jail.enforce_statfs =2 and set it to 0 === mount to /, or 1 === mount to /Folder is not recommended. I checked jail, building on ~ 15 motherboard, when it building on /jail it not start stable. Some users says about such behavior his jails.
See man http://www.freebsd.org/cgi/man.cgi?query=jail&sektion=8
Part examples/
It not have any example with path /jail.
As result security.jail.enforce_statfs =2 - you can not give to work symbolic links and mounts for path / or /Folder

When I created jails on machine with not stable start up bahvior, but jails was building on /mnt/jail or /usr/jail - it was work without problem
raulfg3 wrote:please , no jails wars here, both aproach are valid, one is better for power user that know what do ( dech ) and other is desinged to facilitate life to non power users (thebrig) alexey.
Raul, this is not jail war.
I was have problem with wiki-building jail, and anyone not help me. I begin to learn how it work - and as result we have TheBrig as is. It work on full and embedded version, jail start and shutdown procedures created for very strong way.
Jail is very good idea, but if dech wrote article about it, he need help for another users for understanding and edit article when another user find error
Home12.1.0.4 - Ingva (revision 7091)/ x64-embedded on AMD A8-7600 Radeon R7 A88XM-PLUS/ 16G RAM / UPS Ippon Back Power Pro 600
Lab 12.1.0.4 - Ingva (revision 7091) /x64-embedded on Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz / H61M-DS2 / 4G RAM / UPS Ippon Back Power Pro 600

User avatar
dech
Starter
Starter
Posts: 20
Joined: 10 Apr 2013 19:48
Status: Offline

Re: [HowTo] Setup Jail made simple

Post by dech »

Moin,
yes, your are right with the /jail path. Primary reason I dont notice it cause I use only NFS for my jails. This avoid most of the problems with mounts. When I wrote the wiki article I used nullfs cause people are more familar with this.

dech

User avatar
alexey123
Moderator
Moderator
Posts: 1469
Joined: 19 Aug 2012 08:22
Location: Israel, Karmiel
Contact:
Status: Offline

Re: [HowTo] Setup Jail made simple

Post by alexey123 »

If you mount any for / , also over nfs, you need mount it as read only. This is not a way :D

If you inspect original freebsd etc/rc.d/jail file, you can find strings
# REQUIRE: LOGIN cleanvar
# BEFORE: securelevel
I was send request for change it for nas4free building.
Home12.1.0.4 - Ingva (revision 7091)/ x64-embedded on AMD A8-7600 Radeon R7 A88XM-PLUS/ 16G RAM / UPS Ippon Back Power Pro 600
Lab 12.1.0.4 - Ingva (revision 7091) /x64-embedded on Intel(R) Core(TM) i3-3220 CPU @ 3.30GHz / H61M-DS2 / 4G RAM / UPS Ippon Back Power Pro 600

User avatar
dech
Starter
Starter
Posts: 20
Joined: 10 Apr 2013 19:48
Status: Offline

Re: [HowTo] Setup Jail made simple

Post by dech »

Moin,
the mounts are not in the servers root, they are under /jails/<jailname>/mountpoint

Post Reply

Return to “Jails”