Changes

New page: Fedora Linux uses Network File System (NFS) to allow the file system on one Linux computer to be accessed on over a network connection by another Linux or UNIX system. NFS was originally d...
Fedora Linux uses Network File System (NFS) to allow the file system on one Linux computer to be accessed on over a network connection by another Linux or UNIX system. NFS was originally developed by Sun Microsystems in the 1980's and remains the standard mechanism for sharing of remote Linux/UNIX file systems to this day.

NFS is very different to the Windows SMB resource sharing technology. Accessing Linux based resources from a Windows system is covered in the [[Sharing Fedora Linux Folders with Remote Windows Systems]] chapter of this book. In this chapter we will be looking at network based sharing of folders between Linux and UNIX based systems.

== Ensuring NFS Services are Running on Fedora Linux ==

The first task is to verify that the NFS services are installed and running on your Fedora Linux system. This can be achieved either from the command line, or using the graphical services tool. To verify that the NFS services are running from the command-line, run the following command from a terminal window:

<pre>
su -
/sbin/service nfs status
</pre>

If the services are running you will see output similar to the following:

<pre>
rpc.mountd (pid 3617) is running...
nfsd (pid 3614 3613 3612 3611 3610 3609 3608 3607) is running...
rpc.rquotad (pid 3601) is running...
</pre>

If the service is not running, invoke it using the following command:

<pre>
/sbin/service nfs start
</pre>

To check on the status of NFS using the graphical services tool launch it from the ''System->Administration->Server Settings->Services'' menu option. When the tool loads, scroll down the list of services until you find NFS and click on it. The status of the service will be displayed. The following screenshot show the NFS server running in the tool:

[[Image:E.jpg]]

To initiate the sharing process select the ''System'' desktop menu and click on the ''Shared Folders'' option of the ''Administration'' sub-menu. If the file sharing services have not previously been installed the following dialog will appear:

[[Image:ubuntu_sharing_services_not_installed.jpg]]

if you wish to share folders with both Windows and Linux systems install both SMB and NFS services. If you do not need to provide access for Windows system just install NFS.

== Setting up Ubuntu Linux Folder Sharing ==

Once the appropriate NFS services are installed the next step is to select a folder to share. The ''Shared Folders'' dialog will appear as follows:

[[Image:ubuntu_shared_folders.jpg]]

To share a folder click on the ''Add'' button to display the ''Share Folder'' dialog:

[[Image:ubuntu_shared_folders_add_nfs.jpg]]

Select a folder to share (either by selecting a home directory from the list or using the ''Other...'' option to browse the file system). Finally it is necessary to specify which hosts have access to the folder. To define this click on the ''Add'' button to display the allowed ''Add allowed hosts'' dialog:

[[Image:ubuntu_shared_folders_allowed.jpg]]

Specify the allowed host either by entering the IP address or hostname. Alternatively, enter information to allow access from all systems on the network. Repeat the process to add additional hosts.

Once the settings are configured it may be necessary to restart the NFS services. To do this open a terminal window and enter the following command:

<pre>
sudo /etc/init.d/nfs-kernel-server restart
</pre>

Once the server restarts the shared folder may now be accessed from other Linux systems.

== Accessing Ubuntu Linux Shared Folders ==

The shared folder may be accessed either by mounting it manually from the command-line, or browsing to it using the ''File Browser''. To mount the remote folder from the command line open a terminal window and create folder where you would like the remote folder to be mounted:

<pre>
mkdir /home/demo/demo-folder
</pre>

Next enter the command to mount to the remote folder (in this example we use ubuntu2 as the remote hostname and /home/demo as the remote path - modify these to match your environment):

<pre>
sudo mount ubuntu2:/home/demo /home/demo/demo-folder
</pre>

The remote folder will then be mounted on the local system. Once mounted, the /home/demo/demo-folder will contain the remote folder and all its contents.

To access the remote folder using the Ubuntu ''File Browser'' simply select ''Network'' from the ''Places'' desktop menu and navigate to the remote folder.

== Mounting an NFS Filesystem on System Startup ==

It is possible to configure an Ubuntu Linux system to automatically mount a remote file system each time the system starts up. This is achieved by editing the /etc/fstab file. To do this use sudo to load the /etc/fstab file into your favorite editor. It will likely look something like the following:

<pre>
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
# /dev/sda1
UUID=bcde7125-d38d-4362-bcd8-c64f2b512760 / ext3 defaults,errors=remount-ro 0 1
# /dev/sda5
UUID=b4ff42fa-7c9a-4c26-a640-b0af94f14820 none swap sw 0 0
/dev/hdc /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/fd0 /media/floppy0 auto rw,user,noauto 0 0
</pre>

To mount, for example, a folder with the path /home/demo which resides on a system called ubuntu2 in the local folder with the path /nfsmount add the following line to the fstab file:

<pre>
ubuntu2:/home/demo /nfsmount nfs
</pre>

Next time the system reboots the /home/demo folder on the remote ubuntu2 system will be mounted on the local /nfsmount mount point. All the files in the remote folder can then be accessed as if they resided on the local hard disk drive.

== Unmounting an NFS Mount Point ==

Once a remote file system is mounted using NFS it can be unmounted using the ''unmount'' command with the local mount point as the command-line argument. For example, to unmount our example filesystem mount point requires the use of the following command:

<pre>
sudo umount /nfsmount
</pre>