« HOWTO Setup autofs on FedoraHOWTO:Reinstall Grub2 on Ubuntu »

HOWTO install NFS on Fedora

20/11/10

HOWTO install NFS on Fedora

The Network File System (NFS) was developed to allow machines to mount a disk partition on a remote machine as if it were a local disk. It allows for fast, seamless sharing of files across a network.

I stopped using NFS for remote file systems. When I got autofs working. See my FIXME: update autofs howto and put link here.

The Official HOWTO for NFS is very good you should read it. :p

...

Install The Necessary Software

Install the required rpms and a little GUI app for looking after the directories you want to share.

sudo yum install nfs-utils system-config-nfs

Make tell the system to start the NFS service at boot time. This will set the configuration for all run level to start and or stop NFS as specified by the NFS authors.

sudo /sbin/chkconfig nfs on

Check that the service will at boot time

/sbin/chkconfig --list nfs
nfs   0:off 1:off 2:on 3:on 4:on 5:on 6:off

We can now use the GUI or edit the config file directly to setup some shares. I prefer to edit the files directly as server installs do not usually have X installed and therefore there will be no chance or running a GUI. :-/.

sudo nano /etc/exports

Below is an example of sharing two directories. They are only visible to machines on the local subnet 192.168.0.X. Note the netmask can be written in full of in the abbreviated form. (Why is the word "abbreviated" so long?) Take a look at the man page exports(5) for more details on the options and format of the exports file. Note that white space CAN be significant in the exports file, which is unusual.

/etc/exports
/data 192.168.0.0/255.255.255.0(rw,no_subtree_check,sync)
/home 192.168.0.0/24(rw,no_subtree_check,sync)

After saving the exports file we need to tell the system that they should be exported, us the following command. We only really need the '-ra'. The extra -v turns on verbose mode so we can see what have been exported and how.

sudo /usr/sbin/exportfs -rav

The NFS service can be turned on and off like any other service with stop, start, restart. Use status to see if it is already running. There are a number of other options too.

sudo /sbin/service nfs stop
sudo /sbin/service nfs start
sudo /sbin/service nfs restart
sudo /sbin/service nfs status

Mounting NFS shares

directories that have been shared on another machine can be mounted in a similar way to local disks or storage devices. But first you need to know what is being shared.

To see what shares are available from a remote machine use:

showmount -e linux32
Export list for linux32:
/home 192.168.0.0/255.255.255.0
/data 192.168.0.0/255.255.255.0

Okay, so now we know that linux32 is exporting two shares /home and /data. This will only be useful to us when wee can access the shares from our machine. This we do by mounting them somewhere on our file system. To mount a file system we need a mount point, which is a directory that will be the root of top level for that share.

sudo mkdir /mnt/home /mnt/data
sudo mount linux32:/home /mnt/home
sudo mount linux32:/data /mnt/data

These NFS directories can be unmounted with

sudo umount /mnt/home
sudo umount /mnt/data

These will remain mounted until the machine is rebooted. To make them permanent, that is, they are automatically mounted at boot time. We add an entry to /etc/fstab.

sudo nano /etc/fstab
Example

linux32:/data   /mnt/data   nfs   rw,hard,intr,rsize=32768,wsize=32768    0   0  


linux32:/home   /mnt/home   nfs   rw,hard,intr,rsize=32768,wsize=32768    0   0  

It is a good idea to test this before a reboot in case a mistake was made. Simplest way is to mount all drives not yet mounted in the fstab.

command to hand mount from fstab
sudo mount -a

If all goes well you will be able to access the mount points. Why not try rebooting and double check while everything is still fresh in your mind.


Further Reading

man pages for NFS, showmount, fstab, mount and umount

As usual there is some good information to be found at fedoraproject.org

No feedback yet

Here are a collection of Mini-HOWTOs some of which are too short even for that grand title. I keep them around as it is easier to remember where to look these up that to remember the content of the mini-HOWTO

Search

Contents

powered by b2evolution free blog software