Description
NFS or Network File System is a distributed file system protocol. Through NFS, you can allow a system to share directories and files with others over a network. In NFS file sharing, users and even programs can access information on remote systems almost as if they were residing on a local machine.
NFS is operated in a client-server environment where the server is responsible for managing the authentication, authorization, and management of clients, as well as all the data shared within a specific file system. Upon authorization, any number of clients can access the shared data as if it was present in their internal storage.
We have demands of how to install and configure an NFS server in Linux.
The use case is when Nodeum has to connect to a Linux server as Primary Storage, their are mutliple scenarios and example such as :
- Computing cluster
- Editing Station
- ....
Procedure
Ubuntu
Setting up an NFS server on your Ubuntu system is very simple. All you need to do is to make necessary installations and configurations and you are good to go to connect Nodeum on it.
In this KB, we will explain step by step how to set up an NFS server which will enable you to exchange files from an Ubuntu system with Nodeum.
The Ubuntu version used for this test is Ubuntu 18.04 LTS system.
Step 1: Install NFS Kernel Server
Before installing the NFS Kernel server, we can recommend to update the system’s repository index with that of the Internet through the following apt command as sudo:
$ sudo apt-get update
The above command lets us install the latest available version of a software through the Ubuntu repositories.
Now, run the following command in order to install the NFS Kernel Server on your system:
$ sudo apt install nfs-kernel-server
The system will prompt you with a Y/n option to confirm if you want to continue with the installation. Please enter Y and then hit Enter to continue, after which the software will be successfully installed on your system.
Step 2 (optional): If not created yet, create an empty Export Directory
The directory that has to be shared is called an export directory.
The name can be defined according to your choice; here, the export directory name is “data”.
Use the following command, by specifying a mount folder name according to your need, through the following command as root:
$ sudo mkdir -p /mnt/data |
To allow clients to access the directory, it can be recommended to change permissions through the following commands:
$ sudo chown nobody:nogroup /mnt/data $ sudo chmod 777 /mnt/data |
This will allow all users from all groups on the client system to access "data" folder.
Permissions and privilege can be updated according to your own policies.
Step 3: Allow server access through NFS export file
To allow a client to access the server , it required to define it through the exports file located in system’s /etc folder.
Use the following command in order to open this file :
$ sudo vi /etc/exports |
Once you have opened the file, you can allow access in adding the following line :
/mnt/data xxx.xxx.xxx.xxx (rw, sync ,no_subtree_check) |
Another client with IP : yyy.yyy.yyy.yyy
/mnt/data yyy.yyy.yyy.yyy (rw, sync ,no_subtree_check) |
A complet range of IP : yyy.yyy.yyy/24
/mnt/data yyy.yyy.yyy /24 (rw, sync ,no_subtree_check) |
The permissions “rw,sync,no_subtree_check” permissions defined in
this file mean that the client(s) can perform:
* rw : Read and write operation
* sync: write any change to the disc before applying it
* no_subtree_check : prevent subtree checking
On local filesystems, root usually has full access (read/write) to directories/files inside of it. But for NFS directory mounted from network, root usually has no permission to write to it. The reason that NFS directory is non-accessible to root is likely “root_squash”. There is a way to make root act as on local directory for NFS directory.
To disable root_squash, set the
no_root_squash
option. It turns off root squashing.
/mnt/data yyy.yyy.yyy /24 (rw, sync ,no_root_squash,no_subtree_check) |
Step 4: Apply changes
After making all the above configurations in the host system, it is the time to export the shared directory through the following command as sudo:
$ sudo exportfs -a $ sudo systemctl restart nfs-kernel-server |
Let Us Know What You Thought about this Post.
Put your Comment Below.