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

From Techotopia
Jump to: navigation, search
Line 1: Line 1:
 +
<table border="0" cellspacing="0" width="100%">
 +
<tr>
 +
<td width="20%">[[Configuring an Ubuntu Linux Based Web Server|Previous]]<td align="center">[[Ubuntu Linux Essentials|Table of Contents]]<td width="20%" align="right">[[Sharing Ubuntu Linux Folders with Remote Windows Systems|Next]]</td>
 +
<tr>
 +
<td width="20%">Configuring an Ubuntu Linux Based Web Server<td align="center"><td width="20%" align="right">Sharing Ubuntu Linux Folders with Remote Windows Systems
 +
</td>
 +
</table>
 +
<hr>
 +
 +
 
Ubuntu 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 1980's and remains the standard mechanism for sharing of remote Linux/UNIX file systems to this day.
 
Ubuntu 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 1980's and remains the standard mechanism for sharing of remote Linux/UNIX file systems to this day.
  

Revision as of 20:38, 5 July 2007

PreviousTable of ContentsNext
Configuring an Ubuntu Linux Based Web ServerSharing Ubuntu Linux Folders with Remote Windows Systems


Ubuntu 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 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 Ubuntu 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 based systems.


Contents


Installing the NFS Services on Ubuntu Linux

The services required to enable file system and folder sharing are not installed by default on the desktop edition of Ubuntu Linux. They can easily be installed, however, and are installed when an attempt is first made to share folders.

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:

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:

Ubuntu shared folders.jpg

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

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:

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:

sudo /etc/init.d/nfs-kernel-server restart

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:

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