0

I setup an NFS share on my NFS server with /etc/exports containing / *(rw,no_root_squash,no_subtree_check) Then I do exportfs -a to activate the share and restart the nfs server.

I mount the share with autofs on the client machine with /etc/auto.nfs containing foo -fstype=nfs4,soft,rw,noatime,allow_other server.tld:/

My auto.master contains /mnt/nfs /etc/auto.nfs --timeout=30 --ghost

I restart autofs (systemctl restart autofs.service)

Then I see all directories from the server. But when I try to navigate to mounted serverdisks under /mnt/mounteddiskonserver I can't see anything anymore. No files, no directories, no write permission through nemo file browser on the client machine. I can go to /home/user on the server and see and delete all my files on the server that have same permissions as /mnt/mounteddiskonserver/fileshere.

When I setup the NFS server to share /mnt/mounteddiskonserver specifically with with /etc/exports containing /mnt/mounteddiskonserver *(rw,no_root_squash,no_subtree_check) I can see all files and directories under /mnt/mounteddiskonserver and I can read and write.

1
  • auto.master - that first path should be /mnt/nfs rather than mnt/nfs, shouldn't it? Feb 13, 2022 at 17:07

1 Answer 1

0

Your list of export options for the root filesystem does not include crossmnt. As a result, you must explicitly export each separate filesystem under the NFS server's /mnt if you wish to have them accessible over NFS.

This is actually a good thing, as granting access to /dev over NFS is unlikely to achieve anything very useful, and accessing /proc or /sys over NFS might be confusing or even harmful. (Since devices are accessed by minor & major device numbers, the device nodes on the NFS-mounted /dev would still map to the corresponding devices of the client host. Any kind of caching would likely give you stale data from a NFS-exported /proc.)

You may have your reasons for exporting the root filesystem of your NFS server (which itself would be, in my opinion, a questionable practice), but adding crossmnt to its export options would enable you to shoot yourself in the foot with a multi-barrel Gatling gun if anyone with root access makes a mistake in the NFS client system. If you absolutely must, make a separate /etc/exports line for /mnt and add the crossmnt option to that instead.

1
  • Thanks for the answer. crossmnt was the solution. I do not really need to mount root dir but while playing around with NSF I stumbled upon this behaviour and wondered why it didn't work. I'm satisfied with exporting /mnt/disk/folder alone. Feb 13, 2022 at 21:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .