Sharing Ubuntu 10.x Folders with Remote Linux and UNIX Systems

From Techotopia
Jump to: navigation, search
PreviousTable of ContentsNext
Configuring an Ubuntu 10.x Based Web ServerSharing Ubuntu 10.x Folders with Remote Windows Systems


You are reading a sample chapter from the Ubuntu 10.10 Essentials book.

Purchase the fully updated Ubuntu 20.04 Essentials book in eBook ($9.99) or Print ($36.99) format

Ubuntu 20.04 Essentials Print and eBook (ePub/PDF/Kindle) edition contains 36 chapters and over 310 pages
Buy Print Preview Book

Ubuntu 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 Ubuntu systems to make folders accessible to Windows systems, and also to access Windows based folder shares from Ubuntu. This approach can also be used to share folders between other Linux 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 Ubuntu has been given the most attention in terms of documentation and tools support. The topic of folder sharing using Samba is covered in Sharing Ubuntu 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


Installing NFS Services on Ubuntu

The services required to enable NFS folder sharing are not installed by default on Ubuntu. They can easily be installed, however, by opening a terminal window and entering the following command:

sudo apt-get install nfs-kernel-server

The installation process should automatically start the NFS service. To verify that the service is indeed running, execute the following command:

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

If the output from the above command indicates that the service is not running, it may started as follows:

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

Sharing Folders

Once the NFS service is installed and running, the next step is to configure any folders that are to be shared with remote systems. Any folders which are to be shared are listed in the /etc/exports file which may be edited from a terminal window as follows:

sudo gedit /etc/exports

Each folder that is to be shared via NFS must have an entry in this file. The basic syntax is as follows:

<folder path> <hostname>(permissions) 

For example, to allow a system with the IP address of 192.168.2.24 to access /tmp with read-only access, the following entry would be added to the /etc/exports file:

/tmp	192.168.2.24(ro,sync,no_subtree_check)

Similarly, to also make the folder accessible to a system with the hostname ubuntu2 with read/write permission, the line would read as follows:

/tmp	192.168.2.24(ro,sync,no_subtree_check) ubuntu2(rw,sync,no_sub_tree_check)

Alternatively, to provide read/write access to all hosts, simply use the wildcard character (*):

/tmp    *(rw,sync,no_sub_tree_check)

Once the folder entries have been made in the /etc/exports file, the current settings may be checked at any time by running the exportfs command:

sudo exportfs –a
sudo expoertfs
/tmp          	192.168.2.24

Configuring the Firewall

If the Ubuntu system on which the NFS server is running has a firewall activated, it is essential that the firewall on the NFS server system be configured to allow NFS traffic before any folders can be mounted over the network. For more details on firewall configuration refer to Ubuntu Firewall Basics and Using Firestarter to Configure an Ubuntu Firewall. By default, Ubuntu does not configure a firewall to block NFS traffic. Unless you have specifically configured a firewall since installing Ubuntu it should not, therefore, be necessary to make any changes for NFS to work.

Mounting a Remote NFS Folder

Once a folder has been exported it may then be mounted on a client system using the mount command. To mount a remote folder from the command line, open a terminal window and create a folder where you would like the remote folder to be mounted:

mkdir /tmp/mnt

Next enter the command to mount to the remote folder (in this example we use ubuntu as the remote hostname):

sudo mount ubuntu:/tmp /tmp/mnt

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

Mounting an NFS File System on System Startup

It is possible to configure an Ubuntu 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 ubuntu in the local folder with the path /nfsmount add the following line to the /etc/fstab file:

ubuntu:/home/demo /nfsmount nfs

Next time the system reboots the /home/demo folder on the remote ubuntu 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 file system mount point requires the use of the following command:

sudo umount /nfsmount

You are reading a sample chapter from the Ubuntu 10.10 Essentials book.

Purchase the fully updated Ubuntu 20.04 Essentials book in eBook ($9.99) or Print ($36.99) format

Ubuntu 20.04 Essentials Print and eBook (ePub/PDF/Kindle) edition contains 36 chapters and over 310 pages
Buy Print Preview Book


PreviousTable of ContentsNext
Configuring an Ubuntu 10.x Based Web ServerSharing Ubuntu 10.x Folders with Remote Windows Systems