ls files in directory where a mount is above it

Tags:

Answer: 1

10 hours ago

Not sure on how to phrase the question easily.

I have a directory /mnt/bla in it MAYBE I have many files and directories.

On top of that directory, I mounted some nfs mount.

Is there a way to check if there are files in the directory underlying the mount without unmounting it?

Added by: Kenneth Bruen

Answer: 2

24 hours ago

You can do so using a bind-mount. First you need to create a directory which we use as mount point for the bind-mount:

sudo mkdir /mnt/mymountpoint

(We cannot use /mnt here as suggested in the links in the comments since you have a filesystem mounted on /mnt/bla)

Next step:

sudo mount --bind / /mnt/mymountpoint

Browse to /mnt/mymountpoint/mnt/bla to see what's in the folder. What you see here is the content of /mnt/bla as if nothing were mounted to it.

Move the content of /mnt/mymountpoint/mnt/bla to the location you want or remove the content completely.

Unmount the bind-mount with

sudo umount /mnt/mymountpoint

and remove the mountpoint with

sudo rmdir /mnt/mymountpoint

That's it.

Popular Search

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 1 2 3 4 5 6 7 8 9