10

An NFS share was mounted to /vol/mynfs on a Linux client. It does not show any folders with ls and bash completion does not work in /vol/mynfs too. But after changing to a subdirectory all files are visible.

$ ls /vol/mynfs
total 0
$ cd /vol/mynfs/test
$ ls  # shows all files as expected now.

Why are the files invisible first and how can I make them always visible?

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
Jonas Stein
  • 1,082
  • 3
  • 13
  • 31

3 Answers3

12

I presume that your NFS share is automounted, yes?

Before the share is actually mounted, /vol/mynfs is just an empty directory, so ls shows it as that. Moving to that directory forces the mount to actually happen, so the ls after that shows the contents of the now-mounted directory.

The files will be listable as long as the share is actually mounted. If the share is subsequently unmounted (manually or automatically, after an inactivity timeout), the directory will appear to be empty again.

Something like (cd /vol/mynfs; ls) will force the mount and do the ls, if that's what you need to do for some reason.

Norman Gray
  • 1,326
  • 9
  • 7
0

Make sure you have read permission for that directory.
Try ls -la /vol/mynfs/. and look at the output for ., does your user or group have read access?
You can learn to read the permissions here

If you have execute access but not read you will be able to open the folder and its subdirectories but not be able to list them (your exact issue). Source
You can fix this issue by running (may need to be root/use sudo if you don't own the folder);

chmod u+r /vol/mynfs/.

Which will add read permissions for the user on that folder.

The extra /. in the commands might be needed if it's a symlink, I don't know.

Hashbrown
  • 2,782
  • 4
  • 32
  • 47
-1

I also tried this case.

Solution 1

In my case, I am using QNAP NAS Server.

My NAS Share folder name is 'mynfs'

ssh to QNAP NAS Server and chmod 750 mynfs

chmod 750 /share/NFSv=4/mynfs

After NFS Server side chmod setting, My client side nfs can shows all files and directory, now.

Solution 2

This solution is modify client side /etc/fstab. Below example, 10.0.0.254 is my QNAP NAS Server.

10.0.0.254:/mynfs     /vol/mynfs     nfs     defaults        0       0

modify to

10.0.0.254:/mynfs    /vol/mynfs     nfs     relatime,vers=4.1,rsize=32768,wsize=32768,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,local_lock=none  0       0

After modified /etc/fstab and mount /vol/mynfs again. The files was appear in the /vol/mynfs.

  • Your answer is rather about how to configure a nfs export in general, but no answer to my question. I think this is why someone down voted your answer. – Jonas Stein Jan 04 '22 at 20:58
  • 1
    It's ok! Your problem is exactly my question, but no one can provide a useful solution. I found a solution until I succeeded. Of course, I must share with others and help me take notes myself. I cannot answer why, but I can answer how make them always visible, ^_^! – Andrew Kin Fat Choi Jan 05 '22 at 03:07