NFSv4 Mount Directories and Syntax

  • Thread starter Thread starter Vanadium 50
  • Start date Start date
Join the discussion
Registration is free. Ask a follow-up in this thread, or start your own.
6 replies · 2K views
Messages
35,014
Reaction score
21,725
I am trying to export two different directories using nfs v4.

Today I have, on the server /etc/exports
/aaa 192.168.1.0/255.255.255.0(rw,fsid=0,no_root_squash,async)

and in the clients fstab
192.168.1.1:/ /aaa nfs4 rw 0 0

In principle, I want exports to say
Code:
/aaa        192.168.1.0/255.255.255.0(rw,fsid=0,no_root_squash,async)
/bbb        192.168.1.0/255.255.255.0(ro,fsid=0,no_root_squash,async)

and fstab to say
Code:
192.168.1.1:/aaa/   /aaa   nfs4    rw   0 0
192.168.1.1:/bbb/   /bbb   nfs4    ro   0 0

This will not work, of course. It says tp exports both of these as the root filesystem (fsid=0). However, I can't see quite what to do - I can't make either aaa or bbb the root, and I sure don't want to export /. While I can't be the first person to have done this, the internet seems not to have an example of someone who has done this successfully.
 
Physics news on Phys.org
Trying the HAIL Mary approach and asked chatgpt.

CAVEAT EMPTOR: Please use the response carefully:

To achieve your desired setup, you can use separate exports for each directory (/aaa and /bbb) with unique fsid values. NFSv4 requires that each exported filesystem has a unique fsid. Here's how you can modify your configuration:

On the server in /etc/exports:

bash

/aaa 192.168.1.0/255.255.255.0(rw,no_root_squash,async)
/bbb 192.168.1.0/255.255.255.0(ro,no_root_squash,async)

On the clients in /etc/fstab:

bash

192.168.1.1:/aaa /aaa nfs4 rw 0 0
192.168.1.1:/bbb /bbb nfs4 ro 0 0

With these changes, you are exporting both /aaa and /bbb with appropriate permissions and mounting them separately on the clients. Make sure to run exportfs -ra after modifying /etc/exports to apply the changes.
 
Well, there's a reason why we don't use ChatGPT here...

bbb mounts correctly, but aaa gets a "Stale file handle" message on the client.

This is likely a good example of ChatGPT's failings. It can echo back what most people do, but what I am doing is not what most people are doing.
 
Reply
  • Like
Likes   Reactions: berkeman and jedishrfu
Well, I think the basic flew with ChatGPT is that this is not a good question for it. I am hoping someone who has maybe done something similar can chime in.

I think the problem is the fsid=0. Either there is some simple way to do something else, or there is a trick. For example (and I don't think this is possible) export / as fsid=0, but with no permissions - no read, no write, no nothing. The aaa and bbb can be opened up.

I don't think this trick is possible, but maybe some other trick is.
 
A typical export from some of my home systems

host name hp
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
/srv/nfs1 10.1.1.0/24(rw,async,no_subtree_check,no_root_squash,fsid=1)
/sdb/nfs1 10.1.1.0/24(rw,async,no_subtree_check,no_root_squash,fsid=2)
/media/disk 10.1.1.0/24(rw,async,no_subtree_check,no_root_squash,fsid=3)

host name hp8
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
/usbhd 10.1.1.0/24(rw,sync,no_subtree_check,no_root_squash,fsid=1)
/dlna 10.1.1.0/24(rw,sync,no_subtree_check,no_root_squash,fsid=3)
/usbhd/nmusic 10.1.1.0/24(rw,sync,no_subtree_check,no_root_squash,fsid=4)
/sdc/video/hdc1 10.1.1.0/24(rw,sync,no_subtree_check,no_root_squash,fsid=2)


remote mounts from the fstab file on a user machine
hp.sma2.rain.com://media/disk /media/disk nfs bg,soft 0 0
hp8.sma2.rain.com://dlna /dlna nfs bg,soft 0 0