# devfs not mounting in nullfs jail



## scottro (Jan 25, 2014)

We have our own way of using nullfs to create a template jail, then mount several other jails on top of it.  At one point I did a brief write up of it, for my own use, at http://home.roadrunner.com/~computertai ... sjail.html.  It's based on this handbook page. http://www.freebsd.org/doc/handbook/jai ... ation.html, but is a bit simpler.

Recently, I tried this on FreeBSD-10.  As folks might know, as of FreeBSD-10--actually, the man page has mentioned it earlier, but I've found it to be inconsistent--rather than adding devfs entries to /etc/rc.conf, one adds them to /etc/jail.conf. 

While a standard jail works as expected with this, mounting /dev on a jail's /dev directory, the problem is that  if I use the template method, where both the template jail, using nullfs and the new jail are both mounted on say, /jails/_jails1, devfs doesn't get properly mounted.  If I use the mount command, it will show me that devfs is mounted where I want it to be, on jails/_jail1/dev, all I see on jails/_jail1/dev is null and log.  I can then manually mount devfs with the `mount -t devfs -o  dev /jails/_jail1/dev`
and devfs is mounted, (which makes me suspect that I've missed something somewhere.)
My /etc/jail.conf which works without problem with a standard jail is
	
	



```
jail1 {
      path = /jails/_jail1;
      mount.devfs;
     devfs_ruleset = 4;
     ip4.addr = 192.168.1.196;
     exec.start = "/bin/sh /etc/rc";
     exec stop = "/bin/sh etc/rc.shutdown";
```
I've been able to duplicate this on two machines, but before filing a pr, I'd like to do my best to confirm it's not something that I've missed.


----------



## scottro (Jan 28, 2014)

I've been at this a couple of day now.  Also tried adding the devfs lines to /etc/rc.conf and that had no luck.  A kludgy workaround for anyone else in the same fix, is to add a line to mount devfs in each jail in an /etc/rc.local, but so far, that's the only working solution I've come across.  I've seen a couple of other posts about jails in FreeBSD-10, though none exactly like this.  For what it's worth, if I don't use nullfs, jails work well with the new /etc/jail.conf, devfs mounting as expected.


----------



## scottro (Feb 2, 2014)

In case this comes up for others facing the same or similar problems, I've filed a PR, as I've been able to duplicate it consistently.  

http://www.freebsd.org/cgi/query-pr.cgi?pr=186360


----------



## KdeBruin (Feb 24, 2014)

Don't know if this is solved or not, but after I followed the steps listed in the nullfs jail tutorial I did have /dev properly mounted in my jail. This is without the additional /etc/rc.local using FreeBSD 10.0-RELEASE compiled from revision 262433 sources.

UPDATE: just created a new jail and now /dev is not properly mounted. Back to adding the special mount in /etc/rc.local


----------



## scottro (Feb 24, 2014)

Great, and thank you for letting me know.  I'm going to (though not sure if I will tonight), try updating world and seeing if it helps.


----------



## scottro (Feb 25, 2014)

I just did a buildworld, bringing me to Revision 262459 and still no luck for me.  Thank you again for responding.


----------



## scottro (May 5, 2015)

For anyone still looking at this, on the PR mentioned in my earlier post, http://www.freebsd.org/cgi/query-pr.cgi?pr=186360, someone has mentioned a solution.  In the jail.conf file, I can add

```
exec.prestart = "ls /jails/_myjail/dev";
```

The logic behind it is explained in the comment in the PR, but at any rate, adding that line before the exec.start populates a jail's /dev directory.  I'm not going to say solved, because I think it shouldn't need the line--and also, it doesn't mount the complete /dev, but does mount enough so that one can ssh to the jail and install packages in it, but it's a start.


----------

