Tuesday, October 26, 2010

NFS quick howto for centos 5

To use nfs successfully, you have to configure the server and the client. In this example, the client is 192.168.0.3 and the server is 192.168.0.1. The folder to be shared is /home/sharing, and to be mounted to /mnt on the client

On the server
  1. Make directory that you want to use.
    • # mkdir /home/sharing
  2. Edit /etc/exports, insert the client machine's ip
    • # vi /etc/exports
      • Add this line:
        • /home/sharing 192.168.0.3/255.255.255.255(rw,sync)
      • Save
  3. Edit /etc/hosts.allow
    • # vi /etc/hosts.allow
      • Add this line:
        • portmap: 192.168.0.0/255.255.255.0
      • Save
  4. Start nfs and portmap
    • # /etc/init.d /nfs start
    • # /etc/init.d/portmap start
On the client
  1. Start portmap
    • # /etc/init.d/portmap start
  2. Mount the nfs folder
    • # mount 192.168.0.1:/home/sharing /mnt
  3. Check /var/log/messages for any error that might occur
    • # tailf /var/log/messages
  4. Use mount to check if the folder is mounted properly
    • # mount
      • This should be the output:
        • 192.168.0.1:/home/sharing on /mnt type nfs (rw,addr=192.168.0.1)
  5. Edit /etc/fstab to mount the shared folder on boot
    • # vi /etc/fstab
      • Add this line
        • 192.168.0.1:/mnt/sdb1/backup /mnt nfs rw,hard,intr 0 0
      • Save
You can use 'man exports' to see the options available for /etc/exports

No comments:

Post a Comment