Jail mounted base nullfs sometimes not un-mounted after jail stop

Roy Chan

New Member

Messages: 12

Hello all,

I follow the handbook (https://www.freebsd.org/doc/handbook/jails-application.html) and set up a nginx jail. I use a standard base partition mounted as read-only nullfs, and a skel partition mounted as read-write nullfs. My fstab is shown as follows:
/data/jail/template/base /data/jail/jails/nginx nullfs ro 0 0
/data/jail/skels/nginx /data/jail/jails/nginx/skel nullfs rw 0 0
I specified this fstab file in my jail.conf:
exec.start = "/bin/sh /etc/rc";
exec.stop = "/bin/sh /etc/rc.shutdown && sleep 1";

nginx {
    host.hostname = nginx;
    ip4.addr =;
    path = "/data/jail/jails/nginx";
    mount.fstab = "/data/jail/fstabs/nginx.fstab";
Within the jail, I use port to installed www/nginx with the default option. Everything works fine, but when I trigger service jail stop nginx, sometimes the base partition could not be un-mounted.

I used jail -v to check the output. Sometimes the jail could be stopped with everything clean, but sometimes the output was like:
nginx: run command: /sbin/umount /data/jail/jails/nginx/dev
nginx: run command: /sbin/umount -t nullfs /data/jail/jails/nginx/skel
nginx: run command: /sbin/umount -t nullfs /data/jail/jails/nginx
umount: unmount of /data/jail/jails/nginx failed: Device busy
jail: nginx: /sbin/umount -t nullfs /data/jail/jails/nginx: failed
After this, jls doesn't show this jail. However, the base partition is still mounted. I have no idea why. I've checked the opened files but no files were open. However, when I un-mount the file system from the host system, it was processed smoothly without any difficulties.

This problem sometimes happens but I haven't caught its pattern. I'm not sure if this is an Nginx issue or a jail issue, or just a fault in my configuration. I've checked multiple similar discussions but did not find a solution:

It would be great if you could leave some possible solutions or general ideas about this annoying problem. Many thanks!