jail not found error?
James Gritton
jamie at freebsd.org
Mon Aug 29 14:56:39 UTC 2016
On 2016-08-29 02:52, Grzegorz Junka wrote:
> On 28/08/2016 23:22, James Gritton wrote:
>> On 2016-08-28 15:42, Grzegorz Junka wrote:
>>> I am trying to set up a Centos 6 jail. It fails with the following
>>> error:
>>>
>>> root at ultrabook:~ # service jail start centos6
>>> Starting jails: centos6jls: jail "centos6" not found
>>> .
>>>
>>> I somehow managed to run it once by changing the start script from:
>>>
>>> exec.start = "/bin/sh /etc/rc";
>>>
>>> to
>>>
>>> exec.start = "/etc/rc 3";
>>>
>>> It started once but after I shut it down it shows the same error
>>> again
>>> wherever I am trying to start it. This is what I have configured so
>>> far:
>>>
>>> root at ultrabook:~ # cat /etc/jail.conf
>>> # Use the rc scripts to start and stop jails. Mount jail's /dev.
>>>
>>> #exec.start = "/bin/sh /etc/rc";
>>> #exec.stop = "/bin/sh /etc/rc.shutdown";
>>> exec.clean;
>>>
>>> allow.mount;
>>> mount.devfs;
>>> mount.fstab = "/usr/local/etc/fstab/$name";
>>> devfs_ruleset = 4;
>>>
>>> path = "/j/$name";
>>> host.hostname = "$name.ultrabook.yoonka.com";
>>> exec.consolelog = "/var/log/jail/$name";
>>>
>>> centos6 {
>>> exec.start = "/etc/rc 3";
>>> ip4.addr = 127.0.2.1;
>>> interface = lo0;
>>> }
>>>
>>>
>>> root at ultrabook:~ # cat /usr/local/etc/fstab/centos6
>>> linsys /j/centos6/sys linsysfs rw 0 0
>>> linproc /j/centos6/proc linprocfs rw 0 0
>>> #tmpfs /j/centos6/lib/init/rw tmpfs rw,mode=777 0 0
>>> /devfs /j/centos6/dev devfs rw,ruleset=4 0 0
>>>
>>> I was following this example:
>>>
>>> https://bluehatrecord.wordpress.com/2015/09/19/the-midnight-oil-jailing-centos6-in-freebsd-10-2/
>>> but wanted to use the new configuration files. My system:
>>>
>>> root at ultrabook:~ # uname -a
>>> FreeBSD ultrabook.yoonka.com 10.3-RELEASE FreeBSD 10.3-RELEASE #0
>>> r297264: Fri Mar 25 02:10:02 UTC 2016
>>> root at releng1.nyi.freebsd.org:/usr/obj/usr/src/sys/GENERIC amd64
>>>
>>> How to fix or debug this 'jail "centos6" not found' error and start
>>> the jail?
>>>
>>> Grzegorz
>>
>> I wonder if the jail exists as dying - does it show up in "jls -d"?
>>
>> Also, for a verbose start, try "jail -v -c centos6". That shows
>> commands that are run when creating the jail, and may pinpoint where
>> the trouble is.
>>
>> - Jamie
>
> No, 'jls -d' doesn't show anything but every time I try to start the
> jail new mounts from the jail's fstab are made, e.g. just after
> starting FreeBSD:
>
> linsysfs on /j/centos6/sys (linsysfs, local)
> linprocfs on /j/centos6/proc (linprocfs, local)
> devfs on /j/centos6/dev (devfs, local, multilabel)
> devfs on /j/centos6/dev (devfs, local, multilabel)
>
> Then after trying to start the jail again:
>
> linsysfs on /j/centos6/sys (linsysfs, local)
> linprocfs on /j/centos6/proc (linprocfs, local)
> devfs on /j/centos6/dev (devfs, local, multilabel)
> devfs on /j/centos6/dev (devfs, local, multilabel)
> linsysfs on /j/centos6/sys (linsysfs, local)
> linprocfs on /j/centos6/proc (linprocfs, local)
> devfs on /j/centos6/dev (devfs, local, multilabel)
> devfs on /j/centos6/dev (devfs, local, multilabel)
>
> After unmounting all those and trying again:
>
> root at ultrabook:/home/g # jail -v -c centos6
> centos6: run command: /sbin/ifconfig lo0 inet 127.0.2.1 netmask
> 255.255.255.255 alias
> centos6: run command: /sbin/mount -t linsysfs -o rw linsys
> /j/centos6/sys
> centos6: run command: /sbin/mount -t linprocfs -o rw linproc
> /j/centos6/proc
> centos6: run command: /sbin/mount -t devfs -oruleset=4 . /j/centos6/dev
> centos6: jail_set(JAIL_CREATE) persist name=centos6 allow.mount
> devfs_ruleset=4 path=/j/centos6
> host.hostname=centos6.ultrabook.yoonka.com ip4.addr=127.0.2.1
> centos6: created
> centos6: run command in jail: /etc/rc 3
> centos6: jail_set(JAIL_UPDATE) jid=3 nopersist
> root at ultrabook:/home/g # jls
> JID IP Address Hostname Path
> root at ultrabook:/home/g # jls -d
> JID IP Address Hostname Path
>
> Grzegorz
That all looks good from the jail(8) side of things. By "good" I mean
it's doing what it's expected to do. The jail is created as it should
be, the start command ("/etc/rc 3") is run with no errors, and the jail
is still there when the temporary persist flag is removed.
It's probably that last step that makes the jail go away. jail(8)
initially creates jails with the persist flag set, so it can be sure the
jail is still there for later operations. Unless the flag is mentioned
in the config though, it clears it after everything else is done. The
idea is that once the start commands have been run, there will be some
process still running in the jail to keep it around. I'm guessing that
in your case there isn't one. That may be by design (you don't have any
daemons you want to run, not generally the case) or by error. The next
place to look is in the jail's console log, which will have the output
from that /etc/rc run.
You can make the jail stick around by adding "persist" to the jail.conf
entry. But chances are, you still need to find why the startup commands
aren't doing what you want.
- Jamie
More information about the freebsd-jail
mailing list