# [NAS4Free] Proper unmount of jails managed by ezjail



## Ludwig (May 5, 2015)

How can I proper unmount jails? I have my jails on an encrypted drive and can't detach it properly as long as file systems are mounted. Is there a clean way of unmounting all jail mounts automatically? I am running FreeBSD 9.3.

If I start/stop jails, the same file systems will be mounted without unmounting them. This can't be normal?!

... jail has been started during system boot ...


```
[CMD]> mount | grep myjail[/CMD]
/usr/jails/basejail on /usr/jails/myjail/basejail (nullfs, local, read-only)
devfs on /usr/jails/myjail/dev (devfs, local, multilabel)
fdescfs on /usr/jails/myjail/dev/fd (fdescfs)
procfs on /usr/jails/myjail/proc (procfs, local)
```


```
[CMD]> ezjail-admin stop myjail[/CMD]
Stopping jails: myjail.
```


```
[CMD]> mount | grep myjail[/CMD]
/usr/jails/basejail on /usr/jails/myjail/basejail (nullfs, local, read-only)
devfs on /usr/jails/myjail/dev (devfs, local, multilabel)
fdescfs on /usr/jails/myjail/dev/fd (fdescfs)
procfs on /usr/jails/myjail/proc (procfs, local)
```


```
[CMD]> ezjail-admin start myjail[/CMD]
Configuring jails:.
Starting jails:mount_nullfs: /usr/jails/myjail/basejail: Resource deadlock avoided
myjail.
```


```
[CMD]> mount | grep myjail[/CMD]
/usr/jails/basejail on /usr/jails/myjail/basejail (nullfs, local, read-only)
devfs on /usr/jails/myjail/dev (devfs, local, multilabel)
fdescfs on /usr/jails/myjail/dev/fd (fdescfs)
procfs on /usr/jails/myjail/proc (procfs, local)
fdescfs on /usr/jails/myjail/dev/fd (fdescfs)
procfs on /usr/jails/myjail/proc (procfs, local)
```


----------



## junovitch@ (May 6, 2015)

This works on 10.1-RELEASE.  I don't remember this not working on 9.X but I don't have one readily available to double check the behavior on right now.

`# mount | grep test`

```
zfs/jails/test-jail on /zfs/jails/test-jail (zfs, local, noatime, nfsv4acls)
procfs on /zfs/jails/test-jail/proc (procfs, local)
/zfs/jails/basejail on /zfs/jails/test-jail/basejail (nullfs, local, read-only)
/zfs/homedirs/common_media on /zfs/jails/test-jail/zfs/homedirs/common_media (nullfs, local, read-only)
/zfs/poudriere/data/packages on /zfs/jails/test-jail/pkgrepo (nullfs, local, read-only)
devfs on /zfs/jails/test-jail/dev (devfs, local, multilabel)
fdescfs on /zfs/jails/test-jail/dev/fd (fdescfs)
```

`# ezjail-admin stop test-jail`

```
Stopping jails: test-jail.
```

`# mount | grep test`

```
zfs/jails/test-jail on /zfs/jails/test-jail (zfs, local, noatime, nfsv4acls)
```

Is there anything unique in your general system configuration and have you done any configuration changes for ezjail(7) that could be relevant?


----------



## Ludwig (May 9, 2015)

Thanks for the hint! I run Nas4Free + Finch (http://dreamcat4.github.io/finch/) but everything else runs flawlessly. I have installed FreeBSD 9.3 p13 on a second machine and `ezjail-admin stop myjail` stops the jail and unmount all jail file systems. My jail configuration on my main machine is nothing special. That is really strange. Does someone know which script is responsible for unmounting the jail file systems? Is it possible to debug this process?


----------



## junovitch@ (May 10, 2015)

Alright, so then this would be Nas4Free host -> Finch chroot with 9.3 -> then sysutils/ezjail inside the Finch chroot?  I'm not sure if what ezjail does would be have issues running inside the Finch chroot but I would guess it isn't extensively tested. 

Also, please keep the "PCBSD, FreeNAS, Nas4Free and all other FreeBSD derivatives" thread Thread 7290 in mind.


----------

