3

I have a shared directory on a server - let's call it /home/shared - which is mounted with content from another server via nfs.

When it is unmounted /home/shared is supposed to be empty - however, running du -x on the directory indicates that it is not empty.

I cannot unmount the NFS content to inspect the mount point, since it is in use by others.

Is there any way that I can view/edit the contents of the actual mount point (not the NFS content) while leaving the NFS content mounted for others to use?

Brent
  • 22,857
  • 19
  • 70
  • 102

4 Answers4

8

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.

5

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
MikeyB
  • 39,291
  • 10
  • 105
  • 189
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.

Teddy
  • 5,204
  • 1
  • 23
  • 27
  • As that would prevent other users from accessing the NFS data where they expect to find it, this is not an option. – Brent Apr 08 '10 at 17:26
0

you can mount the device on which your original files reside to another directory then drill down into to get to the contents of the directory.

John
  • 1