[sf-lug] mount ... destination directory needs to be empty (?)

Michael Paoli Michael.Paoli at cal.berkeley.edu
Mon Aug 22 22:53:08 PDT 2016


Sometimes the (current) truth gets more complex.  :-)

Once upon a time, one could mount over a directory - empty or not.
That's still mostly true, but may depend what's doing the mounting
or how.  Some do it without question, some may warn or refuse (by
default) if the directory is not empty.  Forget exactly where I've
seen that behavior, but *somewhere* on *some* Linux distributions,
at least if I'm recalling correctly.

And, once upon a time, after mounting atop a non-empty directory -
I('ll) call that overmount for short - one couldn't get to the
original contents of that directory, until the mount was removed.
Well, that *used* to be the case.  On Linux systems, at least
if they're not too horribly old, there's a way one can get to
the overmounted content.  Just take the underlying mounted
filesystem, and *also* mount it (even temporarily) to some
other mount point.  One can then access the contents via that
other mount point - and even, if desired, clean out and remove
the overmounted content.

Extra/trivia - sometimes when I manage to get into giving
"tougher" interview questions, that - or something around
that is typically one of the questions, ... notably where one
has a significant difference in reported filesystem space
used between examining with df, and examining with du -sx,
what are some of the various things that may be going on to
explain such a discrepancy in total space used?  Well,
overmounts are *one* of several possibilities (but not the
most common ... overmounts probably about 2nd most common).


> From: "Alex Kleider" <akleider at sonic.net>
> Cc: sf-lug at linuxmafia.com
> Subject: Re: [sf-lug] SF-LUG meeting of Monday, 15 August 2016
> Date: Wed, 17 Aug 2016 09:12:50 -0700

> On 2016-08-16 12:01, Rick Moen wrote:
>
>>   partitioning tutorial
>>
>> First hit looks OK:
>> http://www.porteus.org/tutorials/40-partitions/111-tutorial-understanding-partitioning-and-formatting.html
>
> Thanks to Rick for (again, as he so often does) elucidating things  
> and giving sound advice.
>
> Regarding the partitioning tutorial, in it I read the following:
> """#destination directory needs to be empty in order to mount a  
> device to it."""
> I believe this is incorrect.  My understanding is that after  
> mounting, the previous content of that directory will cease to be  
> accessible but that the directory need not be empty before it can be  
> used as a mount point.  I remember in the past making use of this  
> 'feature' as a way of checking if an automated mounting worked as  
> intended- i.e. by having an empty file in the directory with a known  
> name and if after an attempt at mounting, that file is there, one  
> knows that the mount did not succeed.





More information about the sf-lug mailing list