Archive:Docs/Drafts/AdministrationGuide/Servers/NetworkFileSystem

= NFS =

Summary
Purpose: This document covers many of the aspects of configuring and customizing.

Audience: This document is designed for anyone wanting to setup  as an File server.

Assumptions: The Fedora OS is installed, TCP/IP and DNS is configured. User accounts have been added and the reader has access to the root password. Firewall rules are configured to allow for the proper port access, and the user has a basic understanding of vi and bash commands.

Related Documents: The InstallGuide documents the basic install of Fedora. The GettingStarted  documents the basic use of Fedora and gaining access to the CLI. The DNS  assists with configuring DNS for name resolution. UserAccounts documents the steps for creating users and groups. The ConfiguringServices  covers configuring Services.

Lead Writer: MikeDittmeier

Introduction
The Network File System, or, is a daemon that allows other computers to 'mount' a disk partition on another remote computer, and access the files the same as local files and folders. Other services and daemons such as automount can be used to mount remote  shares without user intervention.

Package Requirements
This article makes use of the following packages found in the Fedora Repository:
 * The nfs-utils package provides a daemon for the kernel NFS server and related tools, which provides a much higher level of performance than the traditional Linux NFS server used by most users.
 * Support libraries that are needed by the commands and daemons the nfs-utils RPM
 * Converts RPC numbers to universal addresses. NFS requires the  daemon
 * is a graphical user interface for creating, modifying, and deleting  shares.

Installation
By default  is already included in most fedora installations. To verify  is installed, type the following command: rpm -q nfs-utils this should output the follow results: nfs-utils-1.1.0-6.fc8 If not, then install the  packages by typing: su -c 'yum install -y nfs-utils system-config-nfs nfs-utils-lib' For graphical installs, use Main Menu > Add/Remove Software. This requires the root user password to run. In the Browse tab, click on the Base System group on the left, then select the Base option on the right. Click Apply to have the software and all dependencies installed. You can customize what is installed in the Base grouping by clicking on Optional packages.

Configuring NFS
There are three main configuration files you will need to edit to set up an NFS server:,  , and. The only file used in this section of the chapter is  to get NFS up and running.


 * , Main configuration file
 * , Hosts to allow access
 * , Hosts to deny access

Creating Shares
By default  does not share out any folders or drive volumes. To create the first share, open a shell prompt, and enter the following command to begin editing the  file: su -c 'vim /etc/exports' The  editor window will open to what looks like a new file. This is because the  file has no existing configuration settings at install. The format that will be used to share folders and drive volumes is straightforward: directory hosts(options) Here is a break down of the 2 lines listed: /var/ftp/pub 192.168.1.0/255.255.255.0(ro) /home/public 192.168.1.0/255.255.255.0(rw)
 * directory, This is the directory or volume to be shared
 * hosts, This is a client computer that will have access to the share. The preferred way to list the host is by IP Address, but DNS names can be used. A group of hosts can be configured by entering an IP range such as:
 * options - The options specify the kind of access mentioned hosts will have to the shared directory. Here are some of the most common options:
 * , read only access is granted to the Directory
 * , read and write access is granted to the Directory
 * , by default, access by a remote root users is treated as the user 'nobody'. To allow the same access to a remote 'root' account as the local root user, add this option.


 * , subtree checking verifies the a file being accessed is in a sub folder on the same volume. When sharing an entire drive volume, this option will speed up access to the sub-folders and files.
 * , By default  uses 'sync' transfers, so the   server must send an acknowledgment that the file has been written. Using the   option will speed up file transfers by disabling the acknowledgment.

To share the  folder with read only access, and with sync/no_subtree_check allowed, edit the   file as below:

/var/ftp/pub	192.168.54.0/255.255.255.0(ro,sync,no_subtree_check)

For graphical configurations, use System Menu > Administration > Server Settings > NFS. This requires the root user password to run. Click the [Add]  button. on the Basic Tab Enter the directory to share or click the [Browse]  button and select the directory you want to share. Enter the host or hosts you want to have access to the share.

Select the  by clicking the [Read-only]  or [Read/Write]  radio buttons.

On the General Tab, select the [Disable subtree checking]  and the [Sync write operations on request]  radio buttons.

Click the [OK]  button to save your changes.

In a shell prompt, enter the following command to edit the  file and verify the changes just made: su -c 'vim /etc/exports' The following example should be displayed in the  editor window: /var/ftp/pub                  192.168.54.0/255.255.255.0(ro,sync,no_wdelay,no_subtree_check,nohide) Exit the  editor, and restart the   service to apply the changes by typing: su -c 'service nfs restart' The following should be returned: Shutting down NFS mountd:                                 [  OK  ] Shutting down NFS daemon:                                 [  OK  ] Shutting down NFS quotas:                                 [  OK  ] Shutting down NFS services:                               [  OK  ] Starting NFS services:                                    [  OK  ] Starting NFS quotas:                                      [  OK  ] Starting NFS daemon:                                      [  OK  ] Starting NFS mountd:                                      [  OK  ]

To add additional shares, just add an additional line in the  file for each directory or volume that needs to be shared.

Firewall Configuration
Ports for NFS are assigned dynamically by rpcbind, which causes problems for firewalls. To make firewall configuration easy, use the  file to control which ports are used:


 * TCP and UDP port for mountd (rpc.mountd).
 * TCP and UDP port for status (rpc.statd).
 * TCP port for nlockmgr (rpc.lockd).
 * UDP port nlockmgr (rpc.lockd).

Port numbers specified must not be used by any other service. Configure your firewall to allow the port numbers specified in, as well as TCP and UDP port 2049 (NFS).

Run the  command on the NFS server to see which ports and RPC programs are being used.

NFS Clients
There is little to do to connect a linux system to a remote  share. Open a shell prompt, and create the folder on which you want to mount the remote  share: su -c 'mkdir /media/nfs' Now, enter the following command to mount the remote  share:

su -c 'mount server:/var/ftp/pub /media/nfs' To verify the remote  share is mounted enter the following command at a shell prompt: mount The following line should be included in the output: server:/var/ftp/pub on /media/nfs type nfs (rw,addr=192.168.1.10) Now enter the following to get a directory listing of the  mounted directory: ls /media/nfs There is a distribution folder in the  folder for Fedora that is displayed: f8

Mounting NFS Shares at boot time
To mount a  share permanently during system start up, edit the   file the same way as you would for a local file system. The file system type should be set to. Specify the dump and fsck order (the last two entries), in our case set to zero for demonstration purposes. Our example  should look like below: ... server:/var/ftp/pub /media/nfs    nfs         rw           0    0

Using Automount
Another way to access remote  shares is to use. The difference between using the  daemon and the   file is   will only mount the   share when a file or directory is requested on the   mount point. This will also speed up boot time by not waiting for a responce from the remote  server.

The master configuration for  is the   file. Here is an example file: /misc  /etc/auto.misc /net   -hosts +auto.master The  mount is defined in a seperate file. The  directory is reserver for   mounts. New  mounts should be added to the   file. Here is an example of the  file:

cd             -fstype=iso9660,ro,nosuid,nodev :/dev/cdrom

To add the  share to the , add the following line:

nfs		-ro,soft,intr		server:/var/ftp/pub Save the changes made to the  file and start the   deamon using the following command at a shell prompt: su -c 'service autofs start' Test the changes just made by entering the following command at a shell prompt: ls /misc/nfs the result should be: f8

At this Point  should be up and running, and client systems should have access to the designated directories and volumes on the   server. To enable the  service during system startup, enter the following command at a shell prompt: su -c 'chkconfig --levels 345 nfs on'

This starts the  service on run levels 3, 4 and 5 during start up.