Peeking at the contents of a mount point

Kevin O'Gorman kogorman at gmail.com
Thu Sep 13 04:25:10 UTC 2012


On Wed, Sep 12, 2012 at 8:44 AM, Patrick Asselman <iceblink at seti.nl> wrote:
> On 2012-09-12 16:53, Kevin O'Gorman wrote:
>>
>> On Wed, Sep 12, 2012 at 12:57 AM, Karl Auer <kauer at biplane.com.au> wrote:
>>>
>>> On Wed, 2012-09-12 at 15:40 +1000, Basil Chupin wrote:
>>>>
>>>> On 12/09/12 12:25, Kevin O'Gorman wrote:
>>>> > I recall some time ago seeing a command -- a variant or argument to
>>>> > 'mount' I think -- which allowed you to see the real contents of a
>>>> > mount point while something else was still mounted on it.
>>>> > I've looked back through 2 years of postings and can't find it.
>>>> > Anybody have a clue?
>>>>
>>>> The "real mount point" is what you have mounted on it already. And I
>>>> don't know of any "fake" mount points :-) .
>>>
>>>
>>> A mount point is a directory - like "/". A mount point can contain
>>> files, just like any other directory. If a filesystem is mounted on a
>>> directory that contains files, any files below the mount point are
>>> hidden by the mounted filesystem. If you unmount the filesystem, the
>>> files below the mount point become visible again.
>>>
>>> Try it - put a file in (say) /mnt, then mount something on /mnt. The
>>> file you created will "disappear" - to reappear unharmed when you
>>> unmount the filesystem.
>>>
>>> You can see the contents of the mountpoint under a mounted filesystem by
>>> binding the mount point to another name:
>>>
>>>    mount --bind /mnt /mnt_view
>>>
>>> ... then "ls /mnt_view" should show you the "hidden" files.
>>>
>>> This is from memory, so do please test carefully.
>>>
>>> Regards, K.
>>
>>
>>
>> That's what I thought too, but it does not work.  The --bind option
>> lets me place part of the heirarchy in multiple places, but does not
>> allow me to expose any underlying mount points.
>>
>> For example, my home directory is mounted separately so that any
>> runaway experiments don't use up the disk space of other things, but
>> if I have root do
>>    mount --bind /home/kevin /mnt
>>    ls /mnt
>> I see the same thing as if I just did
>>     ls /home/kevin
>>
>
> If you had files in /mnt and they are hidden due to something mounted on
> /mnt then doing
> mount --bind / /all
> should show the original files under /all/mnt/
>
> Best regards,
> Patrick Asselman

Does not work for me.
My /mnt is not a mount point for me, but /home is.  When I
   mkdir /all
   mount --bind / /all
   ls /all/home
I see the mounted stuff, including the giveaway lost+found

-- 
Kevin O'Gorman

programmer, n. an organism that transmutes caffeine into software.




More information about the ubuntu-users mailing list