Bug 222951

Summary: Re-starting a jail with mount.devfs mounts devfs multiple times
Product: Base System Reporter: VK <vlad-fbsd>
Component: binAssignee: freebsd-jail mailing list <jail>
Status: New ---    
Severity: Affects Only Me CC: dch, emaste
Priority: ---    
Version: 11.1-RELEASE   
Hardware: Any   
OS: Any   

Description VK freebsd_triage 2017-10-12 13:07:17 UTC
Starting a jail that's configured with 'mount.devfs' with `jail -c` does not check if devfs is already mounted and mounts it again.

The problem seems to be when the (nopersist) jail is stopped by itself because all the processes in it have exited, so it wasn't explicitly `jail -r`. When that happens, devfs is not unmounted.

So next time the jail is started, devfs is mounted again, resulting with multiple mounts of devfs into $JAIL_ROOT/dev:

> % mount | grep /zroot/jails/test/dev
> devfs on /zroot/jails/test/dev (devfs, local, multilabel)
> devfs on /zroot/jails/test/dev (devfs, local, multilabel)
> devfs on /zroot/jails/test/dev (devfs, local, multilabel)
> devfs on /zroot/jails/test/dev (devfs, local, multilabel)

If the jail is explicitly stopped with `jail -r`, devfs is unmounted.