Page 1 of 2

New to setting up Jails

Posted: 27 Nov 2012 07:45
by mythrandir52
I am relatively new to setting up Jails and I am having a few issues. Background information is listed below. I followed the Jail How to to create the jail.

I am having 2 main problems
First problem in the how to it want me to use the "pkg_add -r nano" to add nano to the jail. I have run jls and gotten the jail number and then jexec # csh. but i get an error when i try to install the package(see below). I can ping both freebds.org and Google so i know dns resolution is working. I know this is probably something stupid but i cant find it. I setup this jail to install sabnzbd and i am holding off till i know it is fully functional.
Error:

Code: Select all

Error: Unable to get ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.1-release/Latest/nano.tbz: File unavailable (e.g., file not found, no access)
pkg_add: unable to fetch 'ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9.1-release/Latest/nano.tbz' by URL
Second issue is related to mount point coming into the jail. I have mount some of my library folder to folders with the jail using mount_nullfs and if i go to them within the shell I can see all the files and folders. Within the jail though I cant only see empty folders. How do i fix it so the jail can see these mounts. (See the jail_start below for details on the mounts.)

Thank you for any assistance you can provide.


Code: Select all

Version	9.1.0.1 - Sandstorm (revision 509)
Built date	Wed Nov 21 18:19:29 JST 2012
Platform OS	 FreeBSD 9.1-RC3 (reldate 901000)
Platform	 x64-embedded on Intel(R) Atom(TM) CPU D525 @ 1.80GHz
System	ASUSTeK Computer INC. AT5NM10T-I Bios: 0306 02/23/2011
rc.conf.local

Code: Select all

jail_enable="YES"				# enable jails YES|NO
jail_list="proto"				# name of the jails to start "proto www..."
jail_proto_rootdir="/Jail/proto"		# path to our jail
jail_proto_hostname="jail.workgroup"		# hostname 
jail_proto_ip="192.168.0.101"			# ip of the jail 
jail_proto_interface="re0"			# Network Interface to use, 
jail_proto_devfs_enable="YES"			# use devfs 
jail_proto_mount_enable="YES"			# mount YES|NO 
jail_proto_fstab="/Jail/conf/fstab.proto"	# File with Filesystems to mount
jail_start

Code: Select all

mkdir /Jail

mount_nullfs /mnt/Data/Jail /Jail
mount_nullfs /mnt/Data/Library/Movies /mnt/Data/Jail/proto/mnt/Movies 
mount_nullfs /mnt/Data/Library/Music /mnt/Data/Jail/proto/mnt/Music
mount_nullfs /mnt/Data/Library/EBooks /mnt/Data/Jail/proto/mnt/EBooks
mount_nullfs /mnt/Data/Library/AudioBooks /mnt/Data/Jail/proto/mnt/AudioBooks
mount_nullfs /mnt/Data/Library/New /mnt/Data/Jail/proto/mnt/New
mount_nullfs /mnt/Data/Library/TVShows /mnt/Data/Jail/proto/mnt/TVShows

# copy Jail binaries to /usr
cp -r /Jail/conf/root/ /
# link config files to /etc
ln -s /Jail/conf/rc.conf.local /etc
#start all Jails
/etc/rc.d/jail start


Re: New to setting up Jails

Posted: 04 Dec 2012 13:55
by raulfg3
mythrandir52 wrote:First problem in the how to it want me to use the "pkg_add -r nano"
you need to execute

Code: Select all

setenv PACKAGESITE ftp://ftp.freebsd.org/pub/FreeBSD/ports/amd64/packages-9-current/Latest/
this is necesary only if BSD is in RC state, when BSD are 9.1 stable , you don't need it.

mythrandir52 wrote:Second issue is related to mount point coming into the jail
I think that I have the same problem that you, I use your aproach

Code: Select all

mount_nullfs /mnt/Data/Library/EBooks /mnt/Data/Jail/proto/mnt/EBooks
but is best to use fstab.proto or fstab.yournewjail

Code: Select all

/mnt/Data/Library/EBooks /mnt/Data/Jail/proto/mnt/EBooks nullfs rw 0 2
see my dudes on: viewtopic.php?f=79&t=1892

Re: New to setting up Jails

Posted: 10 Dec 2012 18:05
by dasunsrule32
Is there plans to add a GUI for jails in the future? That would be great. :)

Re: New to setting up Jails

Posted: 10 Dec 2012 18:30
by dasunsrule32
Also, when creating a jail, is proto really required or is that just a naming convention that your choosing to go with?

Re: New to setting up Jails

Posted: 10 Dec 2012 21:40
by raulfg3
dasunsrule32 wrote:Is there plans to add a GUI for jails in the future? That would be great.
YES, user Fsbruva are trying to do it, I send a PM to Daisuke too, but not sure if are interested.

Re: New to setting up Jails

Posted: 10 Dec 2012 21:41
by raulfg3
dasunsrule32 wrote:Also, when creating a jail, is proto really required or is that just a naming convention that your choosing to go with?
is only a name convention, you can create a jail named upnp in first place , no needed to name it proto, but useful for first time to copy & paste from wiki

Re: New to setting up Jails

Posted: 11 Dec 2012 17:01
by dasunsrule32
Thanks. :)

Re: New to setting up Jails

Posted: 11 Dec 2012 17:10
by fsbruva
I am working on it. This is the end of semester for me at work, and so my workload has increased for the short term. I am looking forward to the holidays to get an alpha version out.

I suspect I will put the code up on github or something once I get a workable version so we can work more collaboratively. One wrinkle that has recently arisen is that FreeBSD 9.1-Release is out - and the most recent Nas4Free has changed a few things about the webgui structure. The other thing is I find this pretty applicable to my situation: XKCD Comic

Re: New to setting up Jails

Posted: 12 Dec 2012 14:39
by dasunsrule32
fsbruva wrote:I am working on it. This is the end of semester for me at work, and so my workload has increased for the short term. I am looking forward to the holidays to get an alpha version out.

I suspect I will put the code up on github or something once I get a workable version so we can work more collaboratively. One wrinkle that has recently arisen is that FreeBSD 9.1-Release is out - and the most recent Nas4Free has changed a few things about the webgui structure. The other thing is I find this pretty applicable to my situation: XKCD Comic
Cool, now that I understand jails much better, it's not that big of a deal. But for an average user, it could be a nice addition. Yeah, that comic is funny! :)

Re: New to setting up Jails

Posted: 17 Dec 2012 14:59
by fizzgig656
sorry to jump on the back but im look into jails, having issues running the following as root.
# fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/`uname -m`/`uname -m`/`uname -r | cut -d- -f1-2`/base.txz
# fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/`uname -m`/`uname -m`/`uname -r | cut -d- -f1-2`/lib32.txz
both return with file unavailable.

Re: New to setting up Jails

Posted: 17 Dec 2012 15:13
by fsbruva
Ah... that is because you are looking for a folder 9.1-RC3, but that folder is no longer present. Once a release is no longer a release candidate, FreeBSD pulls it off their ftp servers.

Those two lines of code only work when run on a major release of Nas4Free. Three options are: 1. Go find the ftp archives for FreeBSD to get the RC3 files, 2. Manually change the lines of code so that 'uname -r | cut -d- -f1-2' is replaced by a valid release (9.0-RELEASE or 9.1-RELEASE). 3. Upgrade Nas4Free to the latest build (573), which is based of the most recent major FreeBSD version , 9.1-RELEASE.

If you do #3 (recommended), then the line of code from the wiki will work properly. If I have time, I will put an annotation in the wiki to reflect the implications of this error.

Re: New to setting up Jails

Posted: 17 Dec 2012 16:00
by raulfg3
fsbruva wrote:If I have time, I will put an annotation in the wiki to reflect the implications of this error.
thanks a lot

Re: New to setting up Jails

Posted: 26 Dec 2012 07:44
by DanAddz
Hay guys

I've been trying to get minidlna on to my nas and am having trouble with everything haha. I couldn't get it to work and then was told that it can't be put on an embedded os, therefore I have been trying to create a jail. I followed the steps on the wiki and can only get to

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

One I do that it's starts to fetch and gets to 11% and stops to tell me that the file system is full etc.

What am I doing wrong???

Regards
Danaddz

Re: New to setting up Jails

Posted: 26 Dec 2012 09:30
by raulfg3
Where do You create the Jail?

If You create the Jail in your data disk, eg: /mnt/yourpool/Jail You do not have filesystem full.

Please re- read the wiki, You need to fetch into /Jail/work. That reside on /mnt/yourpool/Jail <-your data disk.

Post your previous work to understand what step are bad.

Re: New to setting up Jails

Posted: 26 Dec 2012 10:23
by DanAddz
Thanks for the reply,

i realized that i was using the "/mnt/data" when i dont have a mnt called data haha. therefore i used my mount name and it worked.....for the first fetch.

fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/`uname -m`/`uname -m`/`uname -r | cut -d- -f1-2`/lib32.txz this one comes up with the following code.

fetch: ftp://ftp.freebsd.org/pub/FreeBSD/relea ... /lib32.txz: File unavailable (e.g., file not found, no access)

Why cant i get to the file? what is the new file?

thanks in advance

DanAddz

Re: New to setting up Jails

Posted: 26 Dec 2012 17:44
by raulfg3
You don't need lib32 if your system is i386, You only need if your nas4free is x64 (like is explain in the wiki) , please read carefully the wiki.

Re: New to setting up Jails

Posted: 27 Dec 2012 08:31
by DanAddz
Sorry about that.

I obviously wasn't reading it properly.

I now have been able to get through the wiki but am still having some trouble.

I created the file and copied all the lines but when I reboot the machine nothing happens and when I type in jls it comes up with the
# jls

JID IP Address Hostname

With no ip details etc?

Sorry for so many questions


Note: Please disregard this i have not fixed my problem.

thanks

Re: New to setting up Jails

Posted: 27 Dec 2012 10:03
by raulfg3
I see that at the end, You have a working Jail, congratulations: viewtopic.php?f=79&t=2099

Re: New to setting up Jails

Posted: 29 Dec 2012 08:18
by BraM
Hi,

I'm in the early stages of setting up a jail to run minidlna (at first) and whatever comes later depending on sucess.

Anyway, when I try to fetch the BSD files I get the following errors:

Code: Select all

nas4free:/jail/work# fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/`uname -m`/`uname -m`/`uname -r | cut -d- -f1-2`/base.txz
fetch: ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/9.1-RELEASE/base.txz: No address record
nas4free:/jail/work# fetch ftp://ftp.freebsd.org/pub/FreeBSD/releases/`uname -m`/`uname -m`/`uname -r | cut -d- -f1-2`/lib32.txz
fetch: ftp://ftp.freebsd.org/pub/FreeBSD/releases/amd64/amd64/9.1-RELEASE/lib32.txz: No address record
Running:

Code: Select all

Version	9.1.0.1 - Sandstorm (revision 573)
Built date	Sun Dec 16 14:54:26 JST 2012 
Platform OS	 FreeBSD 9.1-RELEASE (reldate 901000) 
Platform	 x64-embedded on AMD Athlon(tm) II Neo N36L Dual-Core Processor

Re: New to setting up Jails

Posted: 29 Dec 2012 10:04
by raulfg3

Re: New to setting up Jails

Posted: 29 Dec 2012 10:25
by BraM
Ummm....
raulfg3 wrote:If latest=573=9.1release then You need to wait some days to have all packages ready, (9.1 is only one week old, and developers need some days to have all packages precompiled and ready to install using pkg_add.
So...
fsbruva wrote:...Those two lines of code only work when run on a major release of Nas4Free. Three options are: 1. Go find the ftp archives for FreeBSD to get the RC3 files, 2. Manually change the lines of code so that 'uname -r | cut -d- -f1-2' is replaced by a valid release (9.0-RELEASE or 9.1-RELEASE). 3. Upgrade Nas4Free to the latest build (573), which is based of the most recent major FreeBSD version , 9.1-RELEASE.

If you do #3 (recommended), then the line of code from the wiki will work properly....
Now I really am confused.

Re: New to setting up Jails

Posted: 02 Jan 2013 19:42
by fsbruva
BraM -
pkg_add is a different command from fetch. Your first quote of raul is his explaining that pkg_add (which downloads pre-compiled packages and installs them on your system) is not yet functioning for 9.1-RELEASE, because not all the ports have been recompiled or made available for download. My quoted explanation is referring to an entirely different set of files to be downloaded. My explanation reflects that the tarballs needed to create a jail will run properly on the latest build of Nas4Free (I know, because I always test code before I post it).

Your error is a DNS error "No address record." Fix your DNS, and then the command will work.

You can (believe it or not) browse to all of these ftp locations with your browser. Open ftp://ftp.freebsd.org in a browser, and see how it is all laid out. If you can't do that, the fetch has no possibility of functioning properly.

Re: New to setting up Jails

Posted: 05 Jan 2013 03:46
by BraM
fsbruva,

Thanks for the helpful reply.

Code: Select all

You can (believe it or not) browse to all of these ftp locations with your browser. Open ftp://ftp.freebsd.org in a browser, and see how it is all laid out. If you can't do that, the fetch has no possibility of functioning properly.
Thanks for the tip. I have had a good browse through those various directories. The project is on the back-burner for now anyways. I'll pick it back up soon.

Re: New to setting up Jails

Posted: 12 Jan 2013 04:01
by BraM
Ok...

I've managed to create a jail and i can start it manually no problem.

Code: Select all

nas4free:~# /mnt/data/jail/conf/jail_start
mkdir /jail
mount_nullfs /mnt/data/jail /jail
ln -s /jail/conf/rc.conf.local /etc
/etc/rc.d/jail start
Configuring jails:.
Starting jails: minidlna.domain.local.

nas4free:~# jls
   JID  IP Address      Hostname                      Path
     1  192.168.1.150   minidlna.domain.local         /jail/minidlna

nas4free:~# jexec 1 csh
root@minidlna:/ #

After reboot:
nas4free:~# jls
   JID  IP Address      Hostname                      Path

However, I can not get it to start on reboot. I have added the line "/mnt/data/jail/conf/jail_start " (PostInit) to the command scripts section as per the wiki but it seems that it's not working at boot.

Any suggestions?

Re: New to setting up Jails

Posted: 12 Jan 2013 10:31
by raulfg3
Revise wiki, You need to add in webgui in RC.conf a variable named jail_enable=yes

Re: New to setting up Jails

Posted: 12 Jan 2013 22:21
by BraM
Thanks raulfg3 for your help.

But adding variable name of (jail_enable) with a value of (jail_enable=yes) to "System|Advanced|rc.conf|Edit" does not start the jail at boot. Again I can easily start the jail manually from the CL and miniDLNA works fine after that.

Re: New to setting up Jails

Posted: 12 Jan 2013 22:47
by raulfg3
Well you aparently have all good, but do not start after reboot, sorry, perhaps fsbruva that have more knowledge of BSD & Jails can help you, please sent a PM to fsbruva with this post , so he can read the thread and help you.

Re: New to setting up Jails

Posted: 13 Jan 2013 21:44
by misterredman
BraM wrote:Thanks raulfg3 for your help.

But adding variable name of (jail_enable) with a value of (jail_enable=yes) to "System|Advanced|rc.conf|Edit" does not start the jail at boot. Again I can easily start the jail manually from the CL and miniDLNA works fine after that.

What is the content of your "/mnt/data/jail/conf/jail_start" script?

Re: New to setting up Jails

Posted: 14 Jan 2013 06:18
by BraM
misterredman wrote:
What is the content of your "/mnt/data/jail/conf/jail_start" script?

Code: Select all

#!/bin/tcsh -x
#mounting to /jail
mkdir /jail
mount_nullfs /mnt/data/jail /jail
# copy jail binaries to /usr, not needed if N4F is 454 or up
# because Daoyama include needed files, uncoment if you use low .454 version
# cp -r /jail/conf/root/ /
# link config files to /etc
ln -s /jail/conf/rc.conf.local /etc
#start all jails
/etc/rc.d/jail start
Also, /mnt/data/jail/conf/rc.conf.local

Code: Select all

### EXAMPLE - MODIFY TO FIT YOUR NEEDS ###
jail_enable="YES"	# enable jails YES|NO
jail_list="minidlna"	# name of the jails to start "minidlna www..."
jail_minidlna_rootdir="/jail/minidlna"		# path to our jail
jail_minidlna_hostname="minidlna.domain.local"	# hostname 
jail_minidlna_ip="192.168.1.150"		# ip of the jail 
jail_minidlna_interface="em0"		# Network Interface to use, replace on your NAS interface name
jail_minidlna_devfs_enable="YES"		# use devfs 
jail_minidlna_mount_enable="YES"		# mount YES|NO 
jail_minidlna_fstab="/jail/conf/fstab.minidlna"	# File with Filesystems to mount

Re: New to setting up Jails

Posted: 14 Jan 2013 13:39
by fsbruva
Well, if the jail starts manually from the commandline, then the problem is the syntax of your PostInit task.