Jail cannot start / restart

Hello
Often I get the following problem when starting / restarting my jails

Code:
# service jail start sys1
Starting jails: cannot start jail  "sys1":
jail: sys1: cannot redefine variable "name".
jail: sys2: cannot redefine variable "name".
jail: sys3: cannot redefine variable "name".
jail: sys1: jail 1 already exists

After a few minutes, it works normally again.

/etc/jail.conf
Code:
exec.clean;
exec.start += "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown";
exec.system_user = "root";
exec.jail_user = "root";
exec.consolelog = "/var/log/jail_${name}_console.log";
mount.devfs;
mount.fstab = "/etc/fstab.${name}";
allow.mount;
allow.set_hostname = 0;
allow.sysvipc = 0;
allow.raw_sockets = 0;
devfs_ruleset = 4;

sys1 {
        jid = 1;
        name = sys1;
        path = /usr/jail/sys1;
        ip4.addr = 127.0.0.2;
        host.hostname = sys1.local;
        persist;
        interface = lo0;
        allow.sysvipc = 1;
}

sys2 {
        jid = 2;
        name = sys2;
        path = /usr/jail/sys2;
        ip4.addr = 127.0.0.3;
        host.hostname = sys2.local;
        persist;
        interface = lo0;
        allow.sysvipc = 1;
}

sys3 {
        jid = 3;
        name = sys3;
        path = /usr/jail/sys3;
        ip4.addr = xxx.xxx.xxx.xxx, 127.0.0.4;
        ip6.addr = xxx:xxx:xxx;
        host.hostname = website.tld;
        persist;
        interface = em0, lo0;
        allow.sysvipc = 1;
}

Each jail is in its own dataset eg. /usr/jail/sys1, /usr/jail/sys2, /usr/jail/sys3
with base and template method /usr/jail/base /usr/jail/tmpl

/etc/fstab.sys1
Code:
/usr/jail/base /usr/jail/sys1/base nullfs noatime,ro 0 0

/etc/fstab.sys2
Code:
/usr/jail/base /usr/jail/sys2/base nullfs noatime,ro 0 0

/etc/fstab.sys3
Code:
/usr/jail/base /usr/jail/sys3/base nullfs noatime,ro 0 0

Code:
# freebsd-version
11.1-RELEASE-p3

What can cause this problem?

Thanks in advance.
 
Last edited by a moderator:
Well, I think the error says it all; you can't (re)define name. See also jail(8), although I do agree that it's not very explicitly mentioned:

Code:
    name    The jail name.  This is an arbitrary string that identifies a
             jail (except it may not contain a `.').  Like the jid, it can be
             passed to later jail commands, or to jls(8) or jexec(8).  If no
             name is supplied, a default is assumed that is the same as the
             jid.  The name parameter is implied by the jail.conf(5) file
             format, and need not be explicitly set when using the
             configuration file.
So my suggestion is to get rid of the name parameter in your jail definitions.
 
Remove the name and jid from jail.conf. The name is already defined:
Code:
[b]sys1[/b] {
...
}
The actual jid will be the first free JID.
 
Unfortunately without success
Code:
# service jail restart
Stopping jails:.
Starting jails:jail: sys1: jail 1 already exists
ifconfig: : bad value
jail: sys2: /sbin/ifconfig lo0 inet  netmask 255.255.255.255  alias: failed
jail: sys3: jail 3 already exists

next try
Code:
# service jail restart
Stopping jails:.
Starting jails:sys1: created
jail: sys1: /bin/sh /etc/rc: failed
sys1: removed
ifconfig: : bad value
jail: sys2: /sbin/ifconfig lo0 inet  netmask 255.255.255.255  alias: failed
sys3: created
jail: sys3: /bin/sh /etc/rc: failed
sys3: removed

Is there a way to reset the ID assignment?
Because I would like to assign an ID to each cell myself.
 
There must be some way to reset the JID-counter.
Does anyone know how to do that?
By rebooting. There is no way to "reset" the counter. Which is why you shouldn't depend on specific JIDs.
 
By rebooting. There is no way to "reset" the counter. Which is why you shouldn't depend on specific JIDs.
That is, there is the nice practical option to set a static JID, but unfortunately it seems to be baggy. The option to assign JID is very useful for managing the jails.
Code:
     jid     The jail identifier.  This will be assigned automatically to a
             new jail (or can be explicitly set), and can be used to identify
             the jail for later modification, or for such commands as jls(8)
             or jexec(8).
A JID is like a PID and you have no control over either of them.


So what do you see in /var/log/jail_sys1_console.log?
actually, nothing unusual except maybe
jail: sys1: exec /bin/sh: No such file or directory
 
That is, there is the nice practical option to set JID, but unfortunately it seems to be baggy. The option to assign JID is very useful for managing the jails.
TIL... :) Though I still don't understand the rationale for that feature.

actually, nothing unusual except maybe
jail: sys1: exec /bin/sh: No such file or directory
But /usr/jail/sys1/bin/sh exists?
 
Back
Top