jail -r & jail -R

dweimer dweimer at dweimer.net
Fri Feb 14 15:51:23 UTC 2014

I think I may have discovered a bug in the jail management system, if 
you look at the man page for jail.

  -r      Remove the jail specified by jid or name.  All jailed processes
              are killed, and all children of this jail are also removed.

  -R      A variation of the -r option that removes an existing jail 
              out using the configuration file.  No removal-related 
              for this jail will be used - the jail will simply be 

However I have discovered, even though -r says it can take either the 
jail name or jail id, if you use the id it appears to function as if you 
used the -R option instead, whereas using the -r option with the name 
correctly stops the jail with the configuration parameters from the 

I discovered this trying to figure out why the jails devfs system was 
not dismounting, and my exec.poststop script was not running.  I 
discovered that if I used the name instead of id, I didn't run into this 

Can anyone else verify that this is a bug or invalid information in man 
if its not, or do I have something wrong in my configuration, below is a 
sample configuration and steps that can be used to reproduce the issue.

Example /etc/jail.conf:

apache {
         jid = 1;
         host.hostname = apache.mydomainname.com;
         ip4.addr =;
         interface = em0;
         path = /jails/apache/10.0-r260787-2014.02.12;
         exec.start = "/bin/sh /etc/rc";
         exec.stop = "/bin/sh /etc/rc.shutdown";
         exec.prestart = "/jails/apache/prestart.sh";
         exec.poststop = "/jails/apache/poststop.sh";
         exec.consolelog = "/jails/apache/console.log";

repeatable test scenario:

jail -c apache
   all looks good
jail -r apache
   all is right, jail devfs is gone, /jails/apache/proststop.sh ran.
jail -c apache
   all looks good
jail -r 1
   something is wrong
     /jails/apache/10.0-r260787-2014.02.12/dev is still mounted
     /jails/apache/proststop.sh hasn't run
     jail is gone
   do manually cleanup
     umount /jails/apache/10.0-r260787-2014.02.12/dev
     execute /jails/apache/proststop.sh script
jail -c apache
   all looks good
jail -R apache
   As expected
     /jails/apache/10.0-r260787-2014.02.12/dev is still mounted
     /jails/apache/proststop.sh hasn't run
     jail is gone.

    Dean E. Weimer

More information about the freebsd-questions mailing list