Is it possible to view the contents of an underlying NFS mount without unmounting the NFS content?

Solution 1:

It might be easier to:

$ sudo mount --bind /directory_above_the_mount_point /some_temporary_directory

then, the /directory_above_the_mount_point/mount_point remains to show the mounted filesystem and at the same moment you can access the underlying filesystem (mount point) at /some_temporary_directory/mount_point.

Solution 2:

If you want to get a handle into the underlying directory, you could use mount --move to move the share out of the way, cd into the mountpoint, then use mount --move to move it back into place. Shouldn't disrupt anything.

A better option if you just want to view would be to use debugfs (or other equivalent) against the filesystem device itself to check that directory:

challenger:/home/michael # mount
/dev/mapper/system-opensuse on / type ext3 (rw,noatime)
/dev/mapper/system-home on /home type xfs (rw,noatime)
challenger:/home/michael # debugfs /dev/system/opensuse 
debugfs 1.41.9 (22-Aug-2009)
debugfs:  ls /home
 11751  (12) .    2  (4084) ..
debugfs:  quit

Solution 3:

You can move a mount in Linux using mount --move. So if you're OK with a very short window of possible non-accessibility, you could do this:

  1. Make a new temporary directory: mkdir /home/shared-tmp
  2. Do the move: mount --move /home/shared /home/shared-tmp && mv /home/shared /home/shared-old && mkdir /home/shared && mount --move /home/shared-tmp /home/shared
  3. Remove the temporary directory: rmdir /home/shared-tmp

This should leave /home/shared as the mounted directory, /home/shared-old as the old (suspected non-empty) directory.