Setting up an NFS Share on CentOS 5

I had the “pleasure” of setting up an NFS share today on CentOS 5 for the first time. It was actually surprisingly easy to accomplish:

Configure the Server

  1. Make a folder on the sharing server that has oodles of space, I didn’t bother to setup quotas.
    • bash# mkdir /raid5_san/shared
  2. Edit /etc/exports, insert the ip addresses of any machines that will need to access the share like this:
    • bash# vi /etc/exports
    • Add in: /raid5_san/shared 192.168.69.1/255.255.255.255(rw,sync)
    • Save
  3. Edit /etc/hosts.allow
    • bash# vi /etc/hosts.allow
    • Add this line:
    • portmap: 192.168.69.1/255.255.255.255
    • Save
  4. Start nfs and portmap
    • bash# /etc/init.d /nfs start
    • bash# /etc/init.d/portmap start
  5. Make sure that portmap and nfs are set to autostart. You can set this by running /usr/sbin/ntsysv (assuming default scripts are already there in /etc/init.d).

Configure the Client(s)

  1. Start portmap
    • bash# /etc/init.d/portmap start
  2. Mount the nfs folder
    • bash# mount 192.168.69.2:/raid5_san/shared /mnt
  3. Check /var/log/messages for any error that might occur
    • bash# tailf /var/log/messages
  4. Use mount to check if the folder is mounted properly
    • bash# mount
    • This should be the output:
    • 192.168.69.2:/raid5_san/shared on /mnt type nfs (rw,addr=192.168.0.1)
  5. Edit /etc/fstab to mount the shared folder on boot
    • bash# vi /etc/fstab
    • Add this line
    • 192.168.69.2:/raid5_san/shared /mnt nfs rw,hard,intr 0 0
    • Save

You can use ‘man exports’ to see the options available for /etc/exports

Thanks to linuxwave, I tweaked their instructions a bit.

This entry was posted in *nix Admin Stuff and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *