Discussion:
[OpenIndiana-discuss] surprising behaviour of mount
Marc Lobelle
2018-02-08 15:30:13 UTC
Permalink
Hello All,

Today I had a very curious message when trying to mount a file system on
a non-empy directory

cannot mount '/export/home/ml/mydirname': directory is not empty

Afaik, mounting on a non empty directory has always been allowed: the
original contents is just temporarily hidden.

mounting was done automatically as a byproduct of

zpool import -d /dev/lofi szpool

szpool had been created by

zpool create -m /export/home/ml/mydirname szpool /dev/lofi/1

Is there a good reason to prohibit mounting on a non-empty directory in
this case ? Is there a way to avoid this constraint ?

Thanks


Marc
Peter Tribble
2018-02-08 16:42:57 UTC
Permalink
Post by Marc Lobelle
Hello All,
Today I had a very curious message when trying to mount a file system on a
non-empy directory
cannot mount '/export/home/ml/mydirname': directory is not empty
Afaik, mounting on a non empty directory has always been allowed: the
original contents is just temporarily hidden.
zfs has always refused to mount over a non-empty directory by default
Post by Marc Lobelle
mounting was done automatically as a byproduct of
zpool import -d /dev/lofi szpool
szpool had been created by
zpool create -m /export/home/ml/mydirname szpool /dev/lofi/1
Is there a good reason to prohibit mounting on a non-empty directory in
this case ?
It's to stop you making mistakes.
Post by Marc Lobelle
Is there a way to avoid this constraint ?
'zfs mount -O' will override the non-empty check.
--
-Peter Tribble
http://www.petertribble.co.uk/ - http://ptribble.blogspot.com/
Marcel Telka
2018-02-08 17:49:26 UTC
Permalink
Post by Peter Tribble
It's to stop you making mistakes.
And allow you to do different mistakes.
--
+-------------------------------------------+
| Marcel Telka e-mail: ***@telka.sk |
| homepage: http://telka.sk/ |
| jabber: ***@jabber.sk |
+-------------------------------------------+
Jim Klimov
2018-02-09 12:00:35 UTC
Permalink
On Thu, Feb 8, 2018 at 3:30 PM, Marc Lobelle
Post by Marc Lobelle
Hello All,
Today I had a very curious message when trying to mount a file system
on a
Post by Marc Lobelle
non-empy directory
cannot mount '/export/home/ml/mydirname': directory is not empty
Afaik, mounting on a non empty directory has always been allowed: the
original contents is just temporarily hidden.
zfs has always refused to mount over a non-empty directory by default
Post by Marc Lobelle
mounting was done automatically as a byproduct of
zpool import -d /dev/lofi szpool
szpool had been created by
zpool create -m /export/home/ml/mydirname szpool /dev/lofi/1
Is there a good reason to prohibit mounting on a non-empty directory
in
Post by Marc Lobelle
this case ?
It's to stop you making mistakes.
Post by Marc Lobelle
Is there a way to avoid this constraint ?
'zfs mount -O' will override the non-empty check.
Hi,

IIRC one of the rationales is that if you have several pools and import them at once (not in sequential predefined order) and they define parts of the same namespace, you can end up with some datasets "overshadowing" others - unless they are mounted into empty locations (e.g. no empty - or full - dirs there with someone else's mountpoints). So to ensure predictability, this check is there and should stay by default.

To override it there are mount options (for `mount -F zfs` forever - so you could use it for rootfs bits in /etc/vfstab for example, and `zfs mount` more recently I guess). I campaigned for a dataset property to this effect (so e.g. /var/tmp can overshadow a non-empty location always on my boxes), not sure it was made by anyone.

Also note that you can protect mountpoints from getting written into with native (non-GNU) chmod:

/bin/chmod -S+ci /var/tmp

for example. Of course, do it on the parent dataset's empty directory - before anything is mounted into that point. Note this won't work in Solaris 10 (last Sun 10u8 at least).

To make ordered pool imports, see my wiki articles and github repo for wrapping pools into SMF services so you can order dependencies between them (and other services that need their data, e.g. SMF-wrapped zones whose roots or data live on such a pool).

Hope this helps,
Jim Klimov
--
Typos courtesy of K-9 Mail on my Android
Marcel Telka
2018-02-08 17:48:01 UTC
Permalink
Is there a good reason to prohibit mounting on a non-empty directory in this
case ?
IMHO, no.
Is there a way to avoid this constraint ?
Some suggestions are here:
https://www.illumos.org/issues/5579
--
+-------------------------------------------+
| Marcel Telka e-mail: ***@telka.sk |
| homepage: http://telka.sk/ |
| jabber: ***@jabber.sk |
+-------------------------------------------+
Jim Klimov
2018-02-09 12:10:37 UTC
Permalink
Post by Marc Lobelle
Hello All,
Today I had a very curious message when trying to mount a file system on
a non-empy directory
cannot mount '/export/home/ml/mydirname': directory is not empty
Afaik, mounting on a non empty directory has always been allowed: the
original contents is just temporarily hidden.
mounting was done automatically as a byproduct of
zpool import -d /dev/lofi szpool
szpool had been created by
zpool create -m /export/home/ml/mydirname szpool /dev/lofi/1
Is there a good reason to prohibit mounting on a non-empty directory in
this case ? Is there a way to avoid this constraint ?
Thanks
Marc
_______________________________________________
openindiana-discuss mailing list
https://openindiana.org/mailman/listinfo/openindiana-discuss
Afaik, mounting on a non empty directory has always been allowed: the original contents is just temporarily hidden.
Yes for 'mount', no for 'zfs mount'
Post by Marc Lobelle
mounting was done automatically as a byproduct of
zpool import -d /dev/lofi szpool
This implies a 'zfs mount', so...

Jim
--
Typos courtesy of K-9 Mail on my Android

Loading...