Sharing Fedora Linux Folders with Remote Linux and UNIX Systems

From Techotopia
Revision as of 20:14, 27 October 2016 by Neil (Talk | contribs) (Text replacement - "<table border="0" cellspacing="0"> " to "<table border="0" cellspacing="0" width="100%">")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
PreviousTable of ContentsNext
Displaying Fedora Linux Applications Remotely (X11 Forwarding)Sharing Fedora Linux Folders with Remote Windows Systems

Take your Fedora Linux Skills to the Next Level
Fedora 31 Essentials book is now available in Print ($36.99) and eBook ($24.99) editions. Learn more...

Buy Print Preview Book

Fedora provides two mechanisms for sharing files and folders with other systems on a network. One approach is to use technology called Samba. Samba is based on Microsoft Windows Folder Sharing and allows Fedora systems to make folders accessible to Windows systems, and also to access Windows based folder shares from Fedora. This approach can also be used to share folders between other Linux and UNIX based systems as long as they too have Samba support installed and configured. This is by far the most popular approach to sharing folders and in recent versions of Fedora has been given the most attention in terms of documentation and tools support. The topic of folder sharing using Samba is covered in the next chapter (Sharing Fedora Linux Folders with Remote Windows Systems).

Another option, which is targeted specifically at sharing folders between Linux and UNIX based systems uses technology called Network File System (NFS). NFS allows the file system on one Linux computer to be accessed over a network connection by another Linux or UNIX system. NFS was originally developed by Sun Microsystems in the 1980s 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 used by Samba. In this chapter we will be looking at network based sharing of folders between Linux based systems using NFS.


Contents


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:

su -
/sbin/service nfs status

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

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

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

/sbin/service nfs start

To check on the status of NFS using the graphical services tool launch it from the System->Administration->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 shows the NFS server running in the tool:


Checking the status of the NFS services on Fedora

Configuring the Fedora Firewall to Allow NFS Traffic

Next, the firewall needs to be configured to allow NFS traffic. To achieve this, run the Firewall Configuration tool by selecting the System->Administration->Firewall menu option. If the firewall is enabled, make sure that the check box next to NFSv4 is set and then click on Apply and Close. Alternatively, if you are using an alternate firewall solution such as Firestarter, ensure that TCP and UDP ports 2049 are both open to traffic.


Specifying the Folders to be Shared

Now that NFS is running and the firewall has been configured, we need to specify which parts of the file system may be accessed by remote Linux or UNIX systems. This can be achieved by directly editing files, or using the NFS Server Configuration GUI tool. In this section we will use the GUI tool to configure two folders to be shared, and then look at the system configuration file that was modified as an example of how to make these changes manually.

The GUI tool is called system-config-nfs and is not installed by default on recent Fedora releases. To install this tool, open a terminal window (Applications->System Tools->Terminal) and enter the following commands:

su -
yum install system-config-nfs

Once installed, the NFS tool can be launched either from the System->Aministration->NFS menu option, or from the command-line:

system-config-nfs

Once this NFS configuration tool is installed and running the following screen should appear:


The Fedora NFS configuration tool


In order to specify a folder to be exported for sharing via NFS to remote systems, click on the Add button in the toolbar. In the Add NFS Share dialog enter the path to a directory you would like to share, either by typing in the path, or using the Browse button. Select the /tmp directory. We are going to make the /tmp directory of the local system available to all hosts, so enter a '*' in the Hosts field and change the basic permissions to Read/Write so that remote users can both read and write to files on our system. Click on OK to save the settings.

Repeat the above process to export a second directory of your choice, and this time specify the share as read only and allow only one host to access to the share by specifying the remote hostname or IP address.

The main screen of the configuration tool will now display as follows:


Fedora nfs server configured.jpg


To see how the tool has configured the system, we need to edit the /etc/exports file:

gedit /etc/exports

The file will contain the settings we specified in the configuration tool:

/tmp                           *(rw,sync)
/vol1                          192.168.2.21(ro,sync)

It is also possible to view the current share settings from the command-line using the exportfs tool:

/usr/sbin/exportfs

The above command will generate the following output:

/vol1           192.168.2.21
/tmp            <world>

Accessing Fedora Linux Shared Folders

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

mkdir /home/demo/demo-folder

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

su -
mount fedora:/home/demo /home/demo/demo-folder

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 Fedora 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 a Fedora 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 load the /etc/fstab file into your favorite editor as super user:

su -
gedit /etc/fstab

When loaded, it will likely look something like the following:

# This file is edited by fstab-sync - see 'man fstab-sync' for details
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
LABEL=/vol1             /vol1                   ext3    defaults        1 2
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
/dev/sdb5               swap                    swap    defaults        0 0
/dev/hdb                /media/cdrecorder       auto    pamconsole,exec,noauto,managed 0 0
/dev/hda                /media/cdrom            auto    pamconsole,exec,noauto,managed 0 0
/dev/sdc1               /media/usbdisk          ext3    pamconsole,exec,noauto,managed 0 0

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

fedora:/home/demo /nfsmount nfs

Next time the system reboots the /home/demo folder located on the remote fedora system will be mounted on the local /nfsmount mount point. All the files in the remote folder can then be accessed as if they reside 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:

su -
umount /nfsmount

Take your Fedora Linux Skills to the Next Level
Fedora 31 Essentials book is now available in Print ($36.99) and eBook ($24.99) editions. Learn more...

Buy Print Preview Book