Solved [Solved] Jail shutdown does not unmount

When I stop/shutdown jails, the mounts specified in /etc/fstab.jailname do not get unmounted. The explanation by Jamie (maintainer of jails) for the problem is:
If you want to keep track of such things for proper handling in later removal, you should put those options in /etc/jail.conf (or some other config file that you should take care to include in the removal command
line.
Great! What is the proper syntax to include in /etc/fstab.jailname so that nullfs mounts for that jail get unmounted? I already have these, but neither /dev nor the contents of the jail's fstab get unmounted:
Code:
 exec.stop = "/bin/sh /etc/rc.shutdown; umount /dev; umount /etc/fstab.jailname";

Full mail from quote here: http://freebsd.1045724.n5.nabble.com/Re ... 99766.html
 
Re: Jail shutdown does not unmount

I haven't tried it but look at this thread. In the last post he says this worked for him:

Code:
mount.fstab="/etc/fstab.portsbuild";

Disclaimer:
No idea if that'll help, I just found it and wanted to help give some sort of direction :)
 
Re: Jail shutdown does not unmount

@kclark: that setting in /etc/jail.conf is for mounting a specific fstab for a particular jail.

Code:
exec.stop = "/bin/sh /etc/rc.shutdown";
apparently runs the correct code, but the system refuses to execute it, it seems.
jail -v -r myjail
Code:
myjail: run command: /sbin/umount /data/myjail/dev
myjail: run command: /sbin/umount -t nullfs /data/myjail/usr/local
umount: unmount of /data/myjail/usr/local failed: Device busy
jail: myjail: /sbin/umount -t nullfs /data/myjail/usr/local: failed
myjail: run command: /sbin/ifconfig re0 inet 192.168.2.100/32 -alias
 
Last edited by a moderator:
Re: Jail shutdown does not unmount

Well, this thread proves that I should read more manual pages, or at least read up a little more on jails. I wasn't aware of this option (I just discovered mount.fstab in the jail(8) manual page thanks to this thread) and just tried it myself; it works like a charm! It mounts and unmounts.

Just for the record, this is my /etc/fstab.dogma:

Code:
/usr/ports      /usr/jails/dogma/usr/ports      nullfs  rw,noauto       0 0
/usr/ports/distfiles /usr/jails/dogma/usr/ports/distfiles nullfs rw,noauto 0 0
Which I'm referring to in /etc/jail.conf using the option mentioned above. Now; on my end it works both ways. Everything gets mounted and dismounted.

So when looking at your error messages it would appear as if something is keeping your file system(s) busy. So what I would do, right after you tried to remove your jail, is to use fstat to try and determine which kind of process is keeping that mountpoint busy.

Unfortunately its not as straight forward as it can be done on Linux (there you have the lsof command available). So I wrote a script some months ago (gof or "Get Open Files") to do exactly that:

Code:
#!/bin/sh

## Get Open Files; this script accepts a directory as input and
## will list any open files it finds within.

for a in $(fstat -f $1 | grep -v wd | sed -E 's/[[:space:]]+/ /g' |\
   cut -d ' ' -f3 | uniq | grep -v PID); do
        procstat -f $a | grep $1 | grep -v cwd;
done;
It might be able to help you out here.
 
Re: Jail shutdown does not unmount

Hi @ShelLuser,

Good tip for fstat - I just did used grep to filter out the output for unmounted folder. You were right, and it turns out the culprit is gvfsd-trash that is keeping the folder busy.

I'm using the gnome3 merged ports tree from marcuscom (don't ask, still not working), and the problem is very likely with the Nautilus code. I'll be advising them of the problem.

Thanks.
 
Last edited by a moderator:
Back
Top