Personal tools
You are here: Home Fedora Solved Post Install Solutions Sharing files with NFSv4 on Fedora (Server -> Multi)

Sharing files with NFSv4 on Fedora (Server -> Multi)

by renich last modified Mar 24, 2008 12:40 AM

This HowTo explains how to set up the Network File System version 4 on your LAN for multiple shares. It explains, also, how to mount the "exports" on your client.

Applicable to Fedora Versions

  • Fedora Core 6+

Requirements

Everything comes preinstalled on an "out-of-the-box" installation of Fedora Core. The following are only services.

These are the server requirements:
  1. nfs
  2. portmap (optional)
These are the client's requirements:
  1. nfs
  2. nfslock

Doing the Work

Configuring the server:

  1. Open up the necessary port on the firewall (port: 2049). Activate the "Security Level and Firewall" tool. Optionally, if you want to be able to query portmap, open up port: 111:tcp/portmapper:tcp. You will be asked for your root password. Please enter it:
  2. su -c "system-config-securitylevel"
  3. Activate "NFS4" and click "OK".
  4. Edit /etc/idmapd.conf. Enter your root password when prompted:
  5. su -c "gedit /etc/idmapd.conf"
  6. Configure your domain name and change the users to nfsnobody:
  7. [General]
    Domain = example.com

    [Mapping]
    Nobody-User = nfsnobody
    Nobody-Group = nfsnobody
  8. Start the portmap and nfslock services, then start the nfs service. Alternatively, you can use System->Administration->Services or System->Administration->Server Settings->Services GUIs. Please enter the root password when prompted:
    su -c "/sbin/service portmap start"
    su -c "/sbin/service nfslock start"
    su -c "/sbin/service nfs start"
  9. Set portmap, nfslock, and nfs services to start on boot.Alternatively, you can use System->Administration->Services or System->Administration->Server Settings->Services GUIs. Please enter the root password when prompted:
    su -c "/sbin/chkconfig --level 345 portmap on"
    su -c "/sbin/chkconfig --level 345 nfslock on"
    su -c "/sbin/chkconfig --level 345 nfs on"
  10. Create the dirs of the exports inside "/nfs4exports". Enter your root password when prompted:
  11. su -c "mkdir -p /nfs4exports/{share1,share2,share3}"
  12. Edit /etc/fstab:
  13. su -c "gedit /etc/fstab"
  14. Bind the desired shares to the, recently created, dirs at /nfs4exports:
    /path/to/share1		/nfs4exports/share1	none	bind	0 0
    /path/to/share2 /nfs4exports/share2 none bind 0 0
    /path/to/share3 /nfs4exports/share3 none bind 0 0

  15. Remount everything. Enter your root password when prompted:
  16. su -c "mount -a"
  17. Edit /etc/exports. Enter your root password when prompted:
  18. su -c "gedit /etc/exports"
  19. Add your shares here (available to your home network) If you want your shares to be read only, change "rw" to "ro" from these statements:
  20. /nfs4exports			192.168.1.0/255.255.255.0(rw,insecure,no_subtree_check,nohide,fsid=0)
    /nfs4exports/share1 192.168.1.0/255.255.255.0(rw,insecure,no_subtree_check,nohide)
    /nfs4exports/share2 192.168.1.0/255.255.255.0(rw,insecure,no_subtree_check,nohide)
    /nfs4exports/share3 192.168.1.0/255.255.255.0(rw,insecure,no_subtree_check,nohide)
  21. Reload your exports. Please enter your root password when prompted:
  22. su -c "exportfs -rv"
  23. Edit your /etc/hosts.allow file, so your clients are allowed to access your nfs. Please enter your root password when prompted:
  24. su -c "gedit /etc/hosts.allow"
  25. Allow your LAN to access your services:
  26. ALL: 192.168.1.0/255.255.255.0
  27. Reboot:
  28. su -c "/sbin/shutdown -r now"

Configuring the clients:

  1. Edit /etc/idmapd.conf. Enter your root password when prompted:
  2. su -c "gedit /etc/idmapd.conf"
  3. Configure your domain name and change the users to nfsnobody:
  4. [General]
    Domain = example.com

    [Mapping]
    Nobody-User = nfsnobody
    Nobody-Group = nfsnobody
  5. Edit /etc/fstab. Please enter your root password when prompted:
  6. su -c "gedit /etc/fstab"
  7. Create the mounting dirs:
  8. su -c "mkdir /mnt/shares /home/me/share1 /home/he/share2 /home/it/share3"
  9. Add the desired shares:
  10. <ip-address-to-server>:/	/mnt/shares	nfs4	rsize=8192,wsize=8192,timeo=14,intr
    <ip-address-to-server>:/ /home/me/share1 nfs4 rsize=8192,wsize=8192,timeo=14,intr
    <ip-address-to-server>:/ /home/he/share2 nfs4 rsize=8192,wsize=8192,timeo=14,intr
    <ip-address-to-server>:/ /home/it/share3 nfs4 rsize=8192,wsize=8192,timeo=14,intr
  11. Remount everything:
  12. su -c "mount -a"

Troubleshooting

How to test

Next time...

Common problems and fixes

Later...

More Information

RedHat recommends, on RHEL5 Beta Docs, that one should use automount instead of /etc/fstab; which saves resources when sharing to multiple workstations. I haven't had the time to try this configuration. This document will be modified/augmented once I've got the hang of it.

Disclaimer

We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #fedora on irc.freenode.net.

Added Reading

Document Actions

Fedora 7

Posted by bodhizazen at Jul 01, 2007 02:55 AM
This worked perfectly with Fedora 7

I was happy not to have to disable SELinux or my firewall

The only "problem" I had was with exportfs

The command in Fedora 7 is : su -c "/usr/sbin/exportfs -rv"

After you edit /etc/idmapd.conf

Posted by zilles at Aug 30, 2007 07:34 PM
After you edit /etc/idmapd.conf, type "service rpcidmapd restart". That will make it re-read the config file.
Log in


Forgot your password?
New user?