Thursday, September 18, 2008

HowTo: Setup a NFS server on Gentoo

To share the content of my P2P workhorse (1.3Ghz Pentium-M laptop running Gentoo Hardened) across my other Unix like machine I've decided to use NFS (Network File System).

To serve as reminder if I ever need to setup a NFS server on Gentoo and to help anyone seeking help I'll lay down the need steps to achieve success.

First become superuser:
  • $ su
Before setting the sever we need to make sure that client and server machines have support for NFS volumes:
  • # cd /usr/src/linux
  • # make menuconfig
  • check if the following options are enabled in the kernel config:
File Systems --->
Network File Systems --->
<*> NFS file system support
[*] Provide NFSv3 client support
<*> NFS server support
[*] Provide NFSv3 server support
Save your kernel config and re-compile the kernel. If you need help on this please refer to Gentoo's documentation as kernel configuration isn't the focus of this post.

Now install the nfs-utils package from portage:
  • # emerge nfs-utils
Editing the /etc/exports file to identify what are your sharing and to whom:
  • # vim /etc/exports
  • to share the /downloads directory to all computers on 192.168.1 network add the following line:
/downloads 192.168.1.1/24(rw,sync,no_subtree_check)
Let's start the nfs service:
  • # /etc/init.d/nfs start
To have the nfs service starting at boot time:
  • # rc-update add nfs default
Also, the showmount command can be used to display the exports on the server:
  • # showmount -e
If you perform any changes changes to the /etc/exports file, reload it by:
  • # /etc/init.d/nfs reload
I've focused on the basis to setup a home network NFS share on Gentoo, however there are loads of performance tunning flags that can be set on both server and client sides.

For more detailed documentation take a look into:
http://nfs.sourceforge.net/nfs-howto/index.html
http://gentoo-wiki.com/HOWTO_Share_Directories_via_NFS
http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?full=1#book_part1_chap7
http://www.gentoo.org/doc/en/kernel-upgrade.xml

No comments: