Difference between revisions of "Sharing Fedora Linux Folders with Remote Linux and UNIX Systems"

From Techotopia
Jump to: navigation, search
(Specifying the Folders to be Shared)
(Setting up Ubuntu Linux Folder Sharing)
Line 91: Line 91:
 
</pre>
 
</pre>
  
== 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 ==
 
== Accessing Ubuntu Linux Shared Folders ==

Revision as of 19:48, 22 August 2007

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.


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->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:

Fedora nfs config service.jpg

The next step in configuring NFS is to ensure that NFS traffic is not being blocked by the Firewall.

Configuring the Fedora Firewall to Allow NFS Traffic

Next, the firewall needs to be configured to allow NFS traffic. To achieve this, run the Security Level Configuration tool by selecting the System->Administration->Firewall and SELinux menu option. If the firewall is enabled, make sure that the check box next to NFS4 is set and then click on Apply and Close.


Specifying the Folders to be Shared

Now that NFS is running and the firewall has been configured, we need to specifiy 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 which was modified as an example of how to make these changes manually.

The GUI tool is called system-config-nfs and this can be launched either from the System->Aministration->Server Settings menu option, or from the command-line:

system-config-nfs

Note that Fedora does not install this tool by default, so if you are unable to find it, it is likely that it needs to be installed:

su -
yum install system-config-nfs

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

Fedora nfs server configuration.jpg

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 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:

mkdir /home/demo/demo-folder

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):

sudo mount ubuntu2:/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 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:

# /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

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:

ubuntu2:/home/demo /nfsmount nfs

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:

sudo umount /nfsmount