The [[wp>​Network File System]] is the protocol of choice to share files over an internal Local Area Network. Depending on your needs, you may also want to use [[doc:​uci:​samba|Samba]] or the [[sshfs.server|SSH Filesystem]] additionally or instead.

+

===== Preparations =====

+

==== Prerequisites ====

+

- [[doc:​howto:​usb.essentials]] ​ obtain basic support for USB.

+

- [[doc:​howto:​usb.storage]] ​ obtain support for USB storage and mount local filesystem

+

- In your [[doc:​uci:​firewall]] (or see [[doc:​howto:​netfilter]]) open port 111 tcp and udp, and 32777-32780 tcp and udp from your LAN. Following example may not work for you (set the right interface -i ):

| libevent ​ | 1.4.14b-1 ​ | 40436 | The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor or after a timeout has been reached. Furthermore,​ libevent also support callbacks due to signals or regular timeouts. \\ libevent is meant to replace the event loop found in event driven ​ network servers. An application just needs to call event_dispatch() and then add or remove events dynamically without having to change the event loop. |

+

| unfs3 ​| ​ 0.9.22-1 ​ | 32804 | UNFS3 is a user-space implementation of the NFSv3 server specification. It provides a daemon for the MOUNT and NFS protocols, which are used by NFS clients for accessing files on the server. |

+

+

**NOTE:** You do not need all packages: **''​nfs-kernel-server''​** should suffice.

+

+

**NOTE:** You may need to install kmod-loop manually to fix "​mount:​ can't setup loop device: No such file or directory"​ errors. (see https://​dev.openwrt.org/​ticket/​11541)

+

+

=== Client (your PCs) ===

+

GNU/Linux distribution come with pre-installed support for this. So does MacOS X since version 10.2. In case your distribution is missing support, you need to install the client software. ArchLinux offers a Wikipage: [[https://​wiki.archlinux.org/​index.php/​Samba#​Configuration]].

+

+

For Windows download //Microsoft Windows Services for UNIX// from [[http://​www.microsoft.com/​downloads/​details.aspx?​FamilyID=896c9688-601b-44f1-81a4-02878ff11778&​DisplayLang=en|Microsoft]].

+

+

You can also use [[http://​j-ftp.sourceforge.net|JFtp]] as an alternative client.

You can't use the CIDR notation, so ''/​mnt/​sda4 192.168.1.0/​24(rw,​sync,​no_subtree_check)''​ would not work, however the above example does.

+

+

If you set up pivot-root or pivot-overlay,​ use the path on /overlay/ partition, else you cannot export mounted fs.

+

+

Assuming the daemons are already running, use the command ''​exportfs -ar''​ to reload and apply changes on the fly.

+

+

=== Start on boot ===

+

Since //​opkg//​-installed init.d scripts are not enabled nor started by default, you need to do this manually. Same procedure as with most (all?) OpenWrt packages: The first commands will will start them right now, the third and fourth will create the symlinks ''/​etc/​rc.d/​S??​portmap''​ and ''/​etc/​rc.d/​S??​nfsd''​ so they get started on boot:

+

+

<​code>​

+

root@OpenWrt:​~#​ /​etc/​init.d/​portmap start

+

root@OpenWrt:​~#​ /​etc/​init.d/​nfsd start

+

root@OpenWrt:​~#​ /​etc/​init.d/​portmap enable

+

root@OpenWrt:​~#​ /​etc/​init.d/​nfsd enable

+

</​code>​

+

+

After start (and after a reboot) verify with ''​top''​ or ''​ps''​ whether the services are running.\\

+

The following entries should appear in the process list:

+

+

<​code>​

+

/​usr/​sbin/​rpc.mountd -p 32780 ​

+

/​usr/​sbin/​rpc.statd -p 32778 -o 32779

+

/​usr/​sbin/​portmap

+

</​code>​

+

+

Use the ''​netstat -l''​ command to see whether //portmap// is listening on port 111 for both tcp and udp. The //nfsd// process may use varying ports.

+

+

==== Client configuration ====

+

=== Linux-Client ===

+

+

Mount manually:

+

<code bash>

+

sudo mount 192.168.1.254:/​mnt/​share1 /​home/​sandra/​nfs_share

+

</​code>​

+

+

Or mount permanently with entries in the ''/​etc/​fstab''​ on each client PC:

* Check out /​proc/​fs/​nfsd/​max_block_size if client reports other block size then what you have specified. It can be changed if the server is not running, but nfsd mounted. Now you can echo the right value to it. - Updated by fathom

I have TL-WR1043ND from TP-Link by default it has a throughput of 4,5mb/sec, after tweaking the block size, and the mount options it delivers 9,5 mb/sec. Cheers! (Still on wifi it has a speed of 6 mb/s)

+

+

==== Throughput Issues ====

+

Since [[doc:​howto:​netfilter]] will track every connection, if you use MASQUERADING for example, you could disable con-tracking for data connections:​