NFSv4 Mount Directories and Syntax

  • Thread starter Thread starter Vanadium 50
  • Start date Start date
Click For Summary
SUMMARY

This discussion focuses on configuring NFSv4 exports for multiple directories on a server. The user initially attempted to export two directories, /aaa and /bbb, with the same fsid=0, which is not permitted in NFSv4. The solution involves assigning unique fsid values to each export, specifically fsid=0 for /aaa and fsid=1 for /bbb. The user discovered that unmounting the /aaa filesystem and rebooting resolved a "Stale file handle" error, indicating that proper synchronization is crucial for NFS operations.

PREREQUISITES
  • Understanding of NFSv4 architecture and configuration
  • Familiarity with Linux file system permissions and mount options
  • Knowledge of the /etc/exports and /etc/fstab configuration files
  • Basic command line skills for executing exportfs and mount commands
NEXT STEPS
  • Research NFSv4 fsid configuration and its implications on exports
  • Learn about troubleshooting NFS errors, specifically "Stale file handle"
  • Explore advanced NFSv4 features such as access control lists (ACLs)
  • Investigate performance tuning options for NFSv4 mounts
USEFUL FOR

System administrators, network engineers, and anyone involved in configuring or troubleshooting NFSv4 file sharing in Linux environments.

Vanadium 50
Staff Emeritus
Science Advisor
Education Advisor
Gold Member
Dearly Missed
Messages
35,004
Reaction score
21,705
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   Reactions: 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

Replies
2
Views
6K