NFSv4 Mount Directories and Syntax

  • Thread starter Thread starter Vanadium 50
  • Start date Start date
AI Thread Summary
To successfully export two directories using NFSv4, each directory must have a unique fsid value in the server's /etc/exports configuration. The correct setup involves specifying both directories with their respective permissions, such as read-write for /aaa and read-only for /bbb. After modifying the exports, it is necessary to run the command `exportfs -ra` to apply the changes. A common issue encountered is the "Stale file handle" error, which can occur if the /aaa filesystem is not properly unmounted or if the client is not rebooted after changes. The original syntax may work only after unmounting and rebooting, indicating that both actions are required for the changes to take effect. In addition, the configuration examples provided illustrate the need for unique fsid values for different exports, as seen in other systems where multiple directories are successfully exported with distinct fsid settings.
Vanadium 50
Staff Emeritus
Science Advisor
Education Advisor
Gold Member
Messages
35,003
Reaction score
21,703
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.
 
Computer science 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.
 
  • Like
Likes berkeman and jedishrfu
One additional note. I used chatgpt 3.5 as I'm not yet ready to fork over monthly fees for the newer 4.0.
 
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.
 
The good news is the problem is solved. The bad news is I don't know why.

My original syntax works, if and only if you unmount the aaa file system and then reboot. Neither one works by itself. (!)
 
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
 

Similar threads

Back
Top