0

Running CentOS 8

server side: /etc/exports:
/home/share *(ro)

/home and /home/share is owned by root.root and has 755 permissions on directories, 644 permission on files.

 client side:
 mount -t nfs4 server:/ /sharefolder

How do I directly mount /home/share to /sharefolder instead of mounting the root of the fs? If I try "mount -t nfs4 server:/home/share /sharefolder", I get an "Operation not permitted" error

3
  • You wrote /folder/share in your /etc/exports file and you say you're trying to mount /home/share, and then your mount command again says /folder/share... Is it a typo? What folder are you sharing?
    – golder3
    Commented Oct 28, 2021 at 6:26
  • can you see the folder you're sharing ? what does showmount -e output ?
    – golder3
    Commented Oct 28, 2021 at 6:35
  • I get this output from showmount "clnt_create: RPC: Unable to receive" even with selinux and firewall disabled. I can't see the folder, I get "Operation not permitted"
    – eng3
    Commented Oct 28, 2021 at 23:41

2 Answers 2

1

mount -t nfs4 server:/home/share /sharefolder looks like a correct command client-side, and your set-up works for me as I just tested it.

Of course, you must enter the command as root, or use sudo with it. The "Operation not permitted" error message suggests perhaps you accidentally ran the command as a non-root user, or mistyped the share name.

Note that even if you export and mount just server:/home/share, the NFSv4 server will need to auto-generate virtual exports for / and /home. However, these will not be the NFS server's real / nor /home, but virtual read-only directories that only contain the minimum necessary sub-directories to reach the actually-exported directories. Once the share has been mounted, you can see this at /proc/fs/nfsd/exports on the NFS server:

cat /proc/fs/nfsd/exports
# Version 1.1
# Path Client(Flags) # IPs
/home   *(ro,insecure,no_root_squash,sync,no_wdelay,no_subtree_check,v4root,uuid=e4c0fcd4:00b94db3:b63bd9a8:0e705e29,sec=390003:390004:390005:1)
/home/share     *(ro,root_squash,sync,wdelay,no_subtree_check,uuid=e4c0fcd4:00b94db3:b63bd9a8:0e705e29,sec=1)
/       *(ro,insecure,no_root_squash,sync,no_wdelay,no_subtree_check,v4root,fsid=0,uuid=e4c0fcd4:00b94db3:b63bd9a8:0e705e29,sec=390003:390004:390005:1)
1
  • yes, I see the same output in /proc/fs/nfsd/exports. However, I cannot mount server:/home/share, only server:/ However, ls /sharefolder/home/share, gives me "Operation not permitted"
    – eng3
    Commented Oct 28, 2021 at 23:44
0

After a bit of testing I managed to reproduce your problem, and it turns out to be firewall issue. Please make sure firewall is disabled and verify that your nfs share works afterwards.

Assuming that you use firewalld:

sudo systemctl stop firewalld

Once you determine that nfs works as expected you'll want to change your firewall configuration. nfs relies on other daemon processes so in order for nfs to work correctly, you need to let through not only nfs, but also mountd and rpc-bind

sudo firewall-cmd --permanent --add-service=rpc-bind
sudo firewall-cmd --permanent --add-service=mountd
sudo firewall-cmd --permanent --add-service=nfs
sudo firewall-cmd --reload

You can also specify a zone if you want these services allowed only for specific zone by adding i.e. --zone=nfszone

I haven't thoroughly tested this solution and you might need to open additional port in order to have all the functionalities working (i.e. file locking) See https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/storage_administration_guide/s2-nfs-nfs-firewall-config

3
  • I tried turn turning off the firewall and selinux on both sides and still get the error. Note that I'm using nfsv4
    – eng3
    Commented Oct 29, 2021 at 11:56
  • what do you mean 'tried' ? what firewall are you using? can you confirm that it is stopped?
    – golder3
    Commented Oct 29, 2021 at 12:15
  • When I encountered the issue, the first thing I did was turn off the firewall and disable selinux, then remount. I ran into the same error. I verified the firewall was turned off with systemctl status firewalld. I am using firewalld. Note that I am using nfsv4 so rpc-bind is not actually required. The mount "succeeds" even with the firewall on (because I already configured it to allow nfs). The error is when I try to access the folder.
    – eng3
    Commented Oct 30, 2021 at 13:06

You must log in to answer this question.

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