Network filesystems

NFS

The Network Files System (NFS) allows to access files and directories over the network on Linux (Unix) computers. If there is a Windows computer samba is the alternative to nfs. The computer holding those data must have a nfs server and the computer requesting access to the data must have a nfs client.

Note

There are different major versions and therefore incompatibilities. Having everywhere the same version obviously is a good idea.

To work with nfs, the nfs kernel features need to be enabled. The nfs-utils package needs to be installed.

Finally, check if your number assignments for user and group names are consistent between the computers. For additional help see the Ownership chapter.

See also: http://nfs.sourceforge.net/

For Gentoo Linux check also the nfs useflags and the nfs useflags indicating the nfs version.

To get the client and the server emerge nfs-utils on all computers involved.

Nfs server

The configuration file that has to be edited on the server is /etc/exports to define what will be available on the network. See also man exports

        <server directory> <client computer name>(rw)
<other server directory> 192.168.1.33(rw)

or as example

        /home/lindegur/Urs black(rw,async,no_subtree_check)

Either the clients IP address or the name of the computer have to be added. An example to give read only access to the multimedia directory:

        /home/lindegur/media 192.168.1.3(ro,async,no_subtree_check)

Warning

Avoid exporting symlinks

mounting As man 5 exports tells, wildcards in ip addresses might work just per accident, so avoid to use them use a netmask instead.

No space is allowed in front of the ( character.

To give all computer in a home net access us a netmask

        /home/lindegur/media 192.168.1.0/255.255.255.0(ro,async,no_subtree_check)

or in the form counting the bits in the netmask having a 1

        /home/lindegur/media 192.168.1.0/24(ro,async,no_subtree_check)

To start the server (and client) /etc/init.d/nfs start and consider to add it to the init scripts rc-update add nfs default

After editing and when the server is already running type exportfs -a

This is necessary to move the stuff to /var/lib/nfs/xtab.

Some commands to show if the system is happy:

rpcinfo -p to see if the daemons are running

showmount -e to see what the server exports

showmount -a to see who accesses the server

Or directly from the kernel cat /proc/fs/nfs/exports

nfs does not use inetd or xinetd, however it considers the two files /etc/hosts.allow and /etc/hosts.deny. See xinetd for more details.

Nfs client

The data on those computers can simply be mounted as it would be a local disk drive:

mount -t nfs <remote computer>:/<remote directory></local mounting point>

An example:

mount -t nfs 192.168.1.33:/home/lindegur/media /mnt/media

or

mount -t nfs <computername>:/home/lindegur/media /mnt/media

When done do a umount</local mounting point>

It is also possible to have it mounted without typing a lot by using a line in /etc/fstab such as:

<remote computer>:/<remote dir> </local mounting point> nfs user,auto,exec 0 0

After that you can mount -a to get everything mounted that is defined in /etc/fstab . The option auto is quite important, when the server is running during boot of the client the clients mounts the network drives automatically. Otherwise they would have to be mounted manually. If the remote computer is not accessible then boot struggles with retraining to connect and finally after a long time out it continuous with its boot process.

The automounter autofs is a better option since it mounts the network drives just on demand when they are getting accessed.

If your nfs server is not always online you can set noauto in /etc/fstab so it will not cause delays on boot due to failures and retries to connect the unavailable nfs server.

<remote computer>:/<remote directory> </local mounting point> nfs   user,noauto,exec 0 0

If the server is up you simply can mount the drives manually by mount /mnt/<mountpoint>.

Instead using /etc/fstab autofs can be used that mounts the network drive on demand.

Nfs troubles

Since time is moving and the system evolves things can happen:

If you get IP6 errors when start the server then comment or uncomment IP6 stuff in /etc/netconfig.

If you get:

mount.nfs: an incorrect mount option was specified

and run nfs version 3 on a new system you might get in troubles since it wants to take version 4. You can fix that with modifying /etc/fstab to hold the nfsvers=3 parameter:

<remote computer>:<remote directory> <local mounting point> nfs   user,auto,exec,nfsvers=3 0 0

Samba

Samba allows Windows computers to be integrated into a Linux network. Linux computers appear to Windows computers as they would be Windows computers including discs and attached printers. Other way round windows resources can be mounted in Linux file system.

For Gentoo follow https://wiki.gentoo.org/wiki/Samba The configuration is in /etc/samba/smb.conf a default file is installed make a copy from it.

Synonyms:

workgroup is domainname

share is network drive

The samba server running on Linux offers resources as printers and network shares to Windows PC's.


Linurs Servernest startpage