Follow by Email

Blog Archive

Search This Blog

Setup NFS server on Raspberry Pi

NFS is the abbreviation of "Network File System". This is a service that releases or exports directories on a file server to other computers over the network. Other servers or clients can mount these directories.
Share it:
Set up Raspberry Pi NFS server 
NFS is the abbreviation of "Network File System". This is a service that releases or exports directories on a file server to other computers over the network. Other servers or clients can mount these directories. That is, hook in their file system. Including a directory exported by an NFS server on a local client looks to the user as if that directory is on his local machine.

Windows knows something similar. This is the drive or folder share. However, the NFS shares are not so comfortable to use. For Linux, the administrator of a system must know on which machine the NFS shares are located.

The advantage of NFS is that you can use the storage space of other computers on the network as if it were locally available. If certain directories are centrally located on an NFS server, they can be backed up together. However, this server must be reliable and constantly running to ensure the availability of shared directories.

In practice one differentiates between NFSv3 and NFSv4. Although NFSv4 exists, NFSv3 is still a common version for NFS environments. While NFSv4 brings some benefits, it also requires a number of additional services that you need to set up to take advantage of NFSv4.

The following file server solution provides for installing and setting up file access over the network with NFSv3.

tasks
  • Installing the NFS server.
  • Basic configuration of the NFS server.
Solution: Install the NFS server
There are two ways to operate the NFS server. Either he runs in user space or in kernel space. Without going into the special features of both variants, we recommend installing the NFS server for the kernel space.
sudo apt-get update

sudo apt-get install nfs-kernel-server
This loads a lot of packages and installs, which can take some time.

Solution: Basic configuration of the NFS server
A complete configuration of an NFS server is very extensive. In addition to shares, users and permissions must also be set up on the NFS server. With NFSv3, most of the time is spent setting up users and user privileges, which is quite complicated.
Coming soon: A user on a Linux system is identified by his UID and GID. If a user attaches an NFS directory to a client with the UID 1000, the user in this directory receives the rights that the user with the UID 1000 has on the server. The permissions are therefore not taken from the user name, but from the UID.

Because a useful example configuration for an NFS server would also have to include a central user administration and its effort should not be underestimated, we only make a basic configuration that has to do without user administration.

Note: The following basic NFS server configuration is for testing and experimentation. The serious operation of an NFS server goes far beyond this basic configuration and provides a sophisticated user management.

First we have to create a directory on the server, which we want to export afterwards.
sudo mkdir / home / public
Then we would have to set permissions for the users of this directory. We save ourselves the effort and go at this point the irresponsible step and release in this directory everything for all.
sudo chmod ugo + rwx / home / public
At the point again the indication that this procedure is uncertain. What is meant is that "everyone" in this directory can do "everything".

When installing the NFS server, the file "/ etc / exports" was created, in which we have to enter the directories to be exported.
sudo nano / etc / exports
Here we add the following line if the directory is to be read-only:
/ home / public * (ro, sync, no_subtree_check, all_squash)
Here we add the following line if the directory is to be released for reading and writing:
/ home / public * (rw, sync, no_subtree_check, all_squash)
An export line always consists of the directory that is to be exported. This is followed by a "tab" separated, the IP address or the host name of the host or client. An asterisk ("*") stands for "all" in this case. You can also specify an IP address, an IP network address or a host name here.
Immediately thereafter follows without spaces in brackets the desired authorization. "ro" stands for read-only, "rw" for read and write.
"sync" stands for instant writing changes to files and directories. Otherwise, the files are first buffered and possibly only written later.
The specification "no_subtree_check" is necessary

After every change to the file "/ etc / exports" it must be made known and then the NFS server must be restarted.
sudo exportfs -ra

sudo service nfs-kernel-server restart
If messages come in executing these commands, this need not be a serious problem. Nevertheless, one should pursue this. This is usually a configuration problem.

The "rpcinfo" command tells you which RPC services are currently running on the server.
sudo rpcinfo -p
The following services are correct: portmapper, status, nfs, nlockmgr and mountd, each time several times.

Extension: mount / mount NFS shares on the client
In principle, an NFS release always consists of two pages. The server side and the client side. The NFS server was configured successfully in the best case. Now it's about setting up or automatically mount the shared directory to the local file system of a client or other server.
Troubleshooting at NFS
If you have problems with NFS, you usually prefer to run away screaming. To get to the bottom of the problem, you should always be able to rule out network problems. If not, troubleshooting NFS is not worth it.

If network problems are eliminated or eliminated, the first thing to do is check if the NFS server is working properly.
sudo service nfs kernel server status
The "rpcinfo" command tells you which RPC services are currently running on the server.
sudo rpcinfo -p
Alternatives to NFS
Setting up NFS shares is not always easy. If it works, it works well. But there are many pitfalls and sources of error. These range from different NFS versions on client and server, unstable network connections and faulty configurations.
Just then, when the initial configuration becomes ordeal, you quickly look for alternatives. Possible alternative for access to files and directories on remote machines offer FTP and Samba.
Share it:

Raspberry Pi

Post A Comment:

0 comments: