Mount directory from a server to another server in Linux

mounting directories in servers are used to share common files among many servers. mounting a directory from a server to another server in Linux can be done easily by following the below steps. The setup will be as follows;

Remote Server (IP: – the remote server which the directory that will be shared is hosted.

Server 1 (IP: – local server 1

Server 2 (IP: – local server 2

We are mounting through the NFS. NFS which stands for Network File System is a way of sharing directories/files across a network. It is used primarily in Linux and UNIX systems, although there are NFS clients for Windows.

Installing the packages

Install the following in the servers;

Remote Server:

apt-get install nfs-server nfs-comon

Server 1 and Server 2:

apt-get install nfs-kernel-server nfs-comon

Configuring the mount directory

Specify the directory (eg: /shared_mount/share/) to share in the remote server by adding the configurations to /etc/exports:


Then apply those settings;

exportfs -ra
/etc/init.d/nfs-kernel-server restart

Mounting remote directory

Now, mount the directory in the remote server to the local servers;

sudo mount -o soft,intr,rsize=8192,wsize=8192 /local_mount/share/

Testing the mount

To test this mounted setup we will create a file in the remote directory and see if they are available in the mounted directories of the 2 local servers. In the remote mounted directory;

touch /shared_mount/share/hello.txt

now, go and check in the local servers mounted directory. the hello.txt file should be available.

Adding mounting to server startup

This is a good practice to have in case your server goes down or reboots. To add the startup add the following to /etc/fstab in both local servers; /local_mount/share/ nfs rsize=16384,wsize=16384,rw,auto,nolock

2 Replies to “Mount directory from a server to another server in Linux”

  1. user1

    the mounting of remote directory section; it should only be
    sudo mount -o soft,intr,rsize=8192,wsize=8192 /local_mount/share/
    Am I right?

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.