NFSv4 Mount Directories and Syntax

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

Discussion Overview

The discussion revolves around the configuration of NFSv4 exports for multiple directories on a server, specifically addressing issues related to exporting directories with unique filesystem identifiers (fsid) and mounting them correctly on clients. Participants explore syntax, potential pitfalls, and troubleshooting steps.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Exploratory

Main Points Raised

  • One participant outlines their current NFSv4 export configuration and expresses a desire to export two directories with different permissions, questioning the use of fsid=0 for both.
  • Another participant suggests using unique fsid values for each directory export to resolve the issue, providing a modified configuration example.
  • A subsequent reply indicates that while one directory mounts correctly, the other results in a "Stale file handle" error, attributing this to the limitations of automated tools like ChatGPT.
  • Further discussion raises the possibility of exporting the root directory with no permissions as a workaround, although skepticism about its feasibility is expressed.
  • One participant reports a resolution to their issue but admits uncertainty about the exact cause, noting that unmounting and rebooting were necessary steps.
  • Another participant shares examples of their own NFS exports, illustrating different configurations and permissions used in their setups.

Areas of Agreement / Disagreement

Participants do not reach a consensus on the best approach to configuring NFSv4 exports, as multiple viewpoints and experiences are shared without a definitive resolution to the initial problem.

Contextual Notes

Some participants express uncertainty regarding the necessity of unique fsid values and the implications of exporting the root directory. The discussion reflects a variety of configurations and personal experiences, highlighting the complexity of NFSv4 setup.

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