Share your files through your local network – NFS

http://www.pihomeserver.fr/wp-content/uploads/2013/06/NFS_Linux.pngNFS for Network File System, is a file system that allow you to share files over your network, in similar way as local storage.

However, if you are looking for a solution to share files among GNU/Linux and Windows computers, NFS won’t help you much as Windows per default don’t have what it takes to use NFS system. You will want to use Samba instead.

The main advantage of NFS versus Samba for a basic usage is its speed. It performs better than Samba in term of transfer speed, as this old (2010) test shown or this new (2014) test shown too. However NFS is less flexible than Samba in term of permission I’ll say.

So if you are looking for a fast Linux to Linux (Or MacOS) transfer protocol, I strongly recommend you NFS, and here is how to install it.

 

Installation

On your server, you need to install the NFS Server package. In root (or with sudo), type:

apt-get install nfs-kernel-server portmap

and on the client side, you will need nfs-common

apt-get install nfs-common

 

Configuration

Here again, you will need a specific configuration on the server side while the client will only need to mount it.

Server side:

1) You will first need to create a mount point of NFS shares (You may have severals you want to centralized inside a single mount point, or not)

mkdir /export
mkdir /export/Stockage1
mkdir /export/user

2) Then you will need to mount what you want to share in those new folders. Adding a new mount point to a folder will make it available for write and read (if folders/files permissions allow) at 2 places.

mount --bind /media/Stockage1 /export/Stockage1
mount --bind /home/user /export/user

To avoid retyping this after every reboot, you will need to add a fstab entry. Still in root

nano /etc/fstab

and add:

/media/Stockage1        /export/Stockage1         none    bind  0   0
<span class="anchor" id="line-1-6"></span>/home/users    /export/user   none    bind  0  0

(Note that between each of these variables you should not use SPACE but TAB)

and save with CTRL+X (then yes)

3) And finally, enable the export by creating/modifying the file /etc/exports with similar content:

/export       192.168.0.0/24(rw,fsid=0,no_subtree_check,sync)
/export/Stockage1 192.168.0.0/24(rw,nohide,no_subtree_check,sync)
/export/user 192.168.0.0/24(rw,nohide,no_subtree_check,sync)

where 192.168.0.0/24 is the network you want to share with. (The /24 allow all combination of IP for the last 3 digits). Depending on your local network configuration, you may want to correct this entry with 192.168.1.0/24 or whatever IP you want to share with. You can actually list more IP addresses and options on the same line, separated with a space such as:

/export/user 192.168.0.1(rw,no_subtree_check) 192.168.0.2(rw,no_root_squash)

For the option, you can the detail on the man page or directly here.

Once done, you can restart NFS Server:

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

Client side:

You will then simply have to mount the whole export folder or one folder by one folder on your client such as:

mount -t nfs4 192.168.0.100:Stockage1 /media/Stockage/

Where 192.168.0.100 is your server IP.

Note that you may want to create a dedicated folder on the client side, to mount the share.

Or here again, to avoid having to mount it at every reboot, you could add a /etc/fstab entry with:

192.168.0.100:Stockage1  /media/Stockage nfs     rw,hard,intr    0       0

(Here again, there are not space but TAB)
You should now have a working NFS shares on your local network.

Also, having a good server and router will help to achieve higher speed and most probably, your first bottleneck will come from your router and network cables if still in 100M (need cat6 cable and gigabit router for faster transfer speed). On my Western Digital Green 2TO (5400tr/m) that I don’t recommend by the way, I acheive a steadily 80mo/s usually. (I’ve tried SSD to SSD transfer but most probably my router is still the bottleneck for faster transfer, but it will cost me a harm and a leg to have 10G router haha)

 

File Transfer

Gravatar

Loves to discover web-based apps to install on his own server@home and write articles about it

0 Comments:

Add a comment