[2024-feb-29] Sad news: Eric Layton aka Nocturnal Slacker aka vtel57 passed away on Feb 26th, shortly after hospitalization. He was one of our Wiki's most prominent admins. He will be missed.

Welcome to the Slackware Documentation Project

This is an old revision of the document!


NFS - Quick and Dirty Setup

Known to work on Slackware 14 & 14.1

Assumptions

1) This HOWTO assumes that you are using a vanilla install of Slackware and have not changed the default HOSTS_ALLOW, HOSTS_DENY, or firewall rules.
2) For this example, the shared directory on the server will be /nfs_share
3) For this example, the mount point of the NFS share will be /mnt/nfs_share
4) We want anyone on our subnet (192.168.1.x) to have RW access the share

Overview

1) Setup the server
2) Setup the client
3) Mount the NFS directories on the client

Server Setup

Add the NFS shares to the /etc/exports file

vi /etc/exports

add:

/nfs_share 192.168.1.1/24(rw,sync,no_subtree_check)

Start the NFS and RPC daemons

chmod 755 /etc/rc.d/rc.nfsd
chmod 755 /etc/rc.d/rc.rpc
/etc/rc.d/rc.nfsd start
/etc/rc.d/rc.rpc start

Export the shares

exportfs -a

Check to see if the shares are being shared

exportfs

Client Setup

Create the mount point

mkdir /mnt/nfs_share

Start the RPC daemon

chmod 755 /etc/rc.d/rc.rpc
/etc/rc.d/rc.rpc start

Mounting

On the CLIENT machine, you have 3 options here: manually mounting, auto-mount at boot, or semi-auto mount

MANUALLY MOUNT

mount my.nfs.server:/nfs_share /mnt/nfs_share

AUTO-MOUNT AT BOOT
Add the mount command to /etc/fstab

 vi /etc/fstab

add:

my.nfs.server:/nfs_share /mnt/nfs_share nfs rw,defaults 0 0

SEMI-AUTO-MOUNT
Add the mount command to /etc/fstab

 vi /etc/fstab

add:

my.nfs.server:/nfs_share /mnt/nfs_share nfs rw,noauto 0 0

then when you want to mount, just run:

mount /mnt/nfs_share

NOTE ABOUT AUTO_MOUNTING
If you mount at boot and the server machine is unavailable, it will cause your client machine to take a long time to boot as the NFS client will make multiple attempts to connect and you will have to wait for it to time-out for each attampt.

For The Impatient

All the steps with no explanation:
SERVER:

echo "/SHARED_DIR YOUR_SUBNET/24(rw,sync,no_subtree_check)" >> /etc/exports
chmod 755 /etc/rc.d/rc.nfsd
chmod 755 /etc/rc.d/rc.rpc
/etc/rc.d/rc.nfsd start
/etc/rc.d/rpc start
exportfs -a

CLIENT:

mkdir /mnt/nfs_share
chmod 755 /etc/rc.d/rc.rpc
/etc/rc.d/rc.rpc start
echo "YOUR_NFS_SERVER:/SHARED_DIR /CLIENT_MOUNT_POINT nfs rw,defaults 0 0" >> /etc/fstab
mount /CLIENT_MOUNT_POINT

Problems/Solutions

PROBLEM: NFS shares won't mount on client box with a “Stale NFS file handle” error.
SOLUTION:
1) Forcibly unmount the directory on the CLIENT machine (if mounted):

umount -f /mnt/nfs_share

2) Flush the NFS registry on the SERVER machine:

exportfs -f

3) Remount the NFS share

Sources

 howtos:network_services:nfs-quick_and_dirty_setup ()