Setup NFS server on Gentoo

2

Setting up a NFS server on Gentoo doesn’t have to be difficult. Here I will explain how to setup a basic NFS server in just a few steps.

The fist step is to become root.

Your Gentoo kernel must be compiled with support for both NFS server and client. You can check for this in a couple ways.

If you manually built your kernel you can do the following to check for support.

The following options should be enabled in the kernel.

File Systems —>
Network File Systems —>
<*> NFS file system support
[*] Provide NFSv3 client support
<*> NFS server support
[*] Provide NFSv3 server support

It should look similar to this.

make_menuconfig_nfs

Alternatively you may be able to check your configuration settings in /proc/config.gz.

Here are the important lines to look for.

If your configuration lacks these options you will need to rebuild your kernel.

Once you verified your kernel has NFS support go ahead and emerge the nfs-utils package. This package contains all the user-space programs to setup NFS.

You should now edit /etc/exports which tells NFS which filesystems should be shared.

Here is a basic entry example. Here the /mnt/storage directory will be shared to all computers on 192.168.1.* network. The share options will allow for secure read and write access to the NFS volume.

Now start the NFS service.

Congratulations you should now have a working NFS server, but there are still a couple things to do.

Add this service to your default run level. This will automatically start the service every time the system boots.

The showmount command can be used to check which NFS volumes are exported.

If you make any changes to the /etc/exports file you need to reload the NFS service for these changes to take effect.

Share.
  • http://www.dr-jan.com/tips Jan Ives

    I think you probably meant

    # zcat /proc/config.gz | grep NFS

    rather than

    # zcat /proc/config.gz > grep NFS

    • Ryan

      Ah yes, thank you!