Peeking at the contents of a mount point

Karl Auer kauer at
Wed Sep 12 16:01:37 UTC 2012

On Wed, 2012-09-12 at 07:53 -0700, Kevin O'Gorman wrote:
> > 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.

You forced me to go check. As I stated it, I was indeed wrong. I should
have expressed myself more carefully. If you use --bind to "alias" a
directory, then the contents of that directory remain available under
the alias, even if the directory is later used as the mountpoint for
another filesystem.

That is, you can "protect" the contents of a directory so that they
remain accessible, but you have to do it before the directory is used as
a mountpoint:

kauer at karl:~$ ls /mnt
kauer at karl:~$ mkdir fred
kauer at karl:~$ touch fred/blah
kauer at karl:~$ ls fred
kauer at karl:~$ sudo mount --bind /home/kauer/fred /mnt
kauer at karl:~$ ls /mnt
kauer at karl:~$ sudo mount -o loop ubuntu.iso /home/kauer/fred
mount: warning: /home/kauer/fred seems to be mounted read-only.
kauer at karl:~$ ls fred
autorun.inf  dists     md5sum.txt  preseed             usb-creator.exe
boot         install   pics        README.diskdefines  wubi.exe
casper       isolinux  pool        ubuntu
kauer at karl:~$ ls /mnt

Regards, K.

> 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
> -- 
> Kevin O'Gorman
> programmer, n. an organism that transmutes caffeine into software.

Karl Auer (kauer at

GPG fingerprint: AE1D 4868 6420 AD9A A698 5251 1699 7B78 4EEE 6017
Old fingerprint: DA41 51B1 1481 16E1 F7E2 B2E9 3007 14ED 5736 F687

More information about the ubuntu-users mailing list