How to Install and Configure NFS on Linux Mint 20
To Install and configure NFS on Linux Mint 20
Introduction:
The Network File System (NFS) is a client/server application that allows a user to store and update files on a remote computer through the Network. This tutorial will cover the installation and configuration of NFS on Linux Mint 20.
Installation Procedure:
Check the version of Linux Mint OS
root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID: Linuxmint
Description: Linux Mint 20
Release: 20
Codename: ulyana
Install the NFS server by executing the following command
root@linuxhelp:~# apt install nfs-kernel-server -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
Setting up libnfsidmap2:amd64 (0.25-5.1ubuntu1) ...
.
.
.
Creating config file /etc/exports with new version
Creating config file /etc/default/nfs-kernel-server with new version
Processing triggers for systemd (245.4-4ubuntu3) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...
After the installation now create a directories for sharing to the client
root@linuxhelp:~# mkdir /home/test
root@linuxhelp:~# mkdir /home/test2
After the directories is created then give the permission of those directories
root@linuxhelp:~# chmod -R 777 /home/test /home/test2
After that now I am give the access to folders for share to the clients
root@linuxhelp:~# vim /etc/exports
Add the following line to the file
/home/test 192.168.6.116(ro,sync,no_subtree_check)
/home/test2 192.168.6.116(rw,sync,no_subtree_check)
After the access is given then restart the NFS service by executing the following command
root@linuxhelp:~# systemctl restart nfs-kernel-server.service
After that export the share folders by using the following command
root@linuxhelp:~# exportfs -a
Now I will view if the folders is shared or not to the client
root@linuxhelp:~# showmount -e
Export list for linuxhelp:
/home/test2 192.168.6.116
/home/test 192.168.6.116
After that I am move on to my Client Machine, in here I using Ubuntu on my client machine on my client machine also I install nfs server to access the folders from the server by executing following command
root@linuxhelp:~# apt install nfs-kernel-server -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
.
.
.
Creating config file /etc/exports with new version
Creating config file /etc/default/nfs-kernel-server with new version
Processing triggers for systemd (245.4-4ubuntu3.2) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9) ...
After the installation is completed. Now check the if the folders from the server is shared or not
root@linuxhelp:~# showmount -e 192.168.6.119
Export list for 192.168.6.119:
/home/test2 192.168.6.116
/home/test 192.168.6.116
Create some folders for mount the share folders form the server
root@linuxhelp:~# mkdir /mnt/test
root@linuxhelp:~# mkdir /mnt/test2
Now I will check the drive is any share folder is mounted or not by executing the following command
root@linuxhelp:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 953M 0 953M 0% /dev
tmpfs 196M 1.6M 195M 1% /run
/dev/sda5 20G 7.7G 11G 43% /
tmpfs 980M 0 980M 0% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 980M 0 980M 0% /sys/fs/cgroup
/dev/loop0 55M 55M 0 100% /snap/core18/1880
/dev/loop1 56M 56M 0 100% /snap/core18/1932
/dev/loop2 256M 256M 0 100% /snap/gnome-3-34-1804/36
/dev/loop3 218M 218M 0 100% /snap/gnome-3-34-1804/60
/dev/loop4 63M 63M 0 100% /snap/gtk-common-themes/1506
/dev/loop5 50M 50M 0 100% /snap/snap-store/467
/dev/loop6 51M 51M 0 100% /snap/snap-store/481
/dev/loop7 30M 30M 0 100% /snap/snapd/8542
/dev/loop8 31M 31M 0 100% /snap/snapd/9721
/dev/sda1 511M 4.0K 511M 1% /boot/efi
tmpfs 196M 12K 196M 1% /run/user/125
tmpfs 196M 36K 196M 1% /run/user/1000
after that I am mount the share folders to the newly created folders of my client machine
root@linuxhelp:~# mount -t nfs 192.168.6.119:/home/test /mnt/test
root@linuxhelp:~# mount -t nfs 192.168.6.119:/home/test2 /mnt/test2
Now I am view the drive for the folders are mounted correctly on the disk
root@linuxhelp:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 953M 0 953M 0% /dev
tmpfs 196M 1.6M 195M 1% /run
/dev/sda5 20G 7.7G 11G 43% /
tmpfs 980M 0 980M 0% /dev/shm
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 980M 0 980M 0% /sys/fs/cgroup
/dev/loop0 55M 55M 0 100% /snap/core18/1880
/dev/loop1 56M 56M 0 100% /snap/core18/1932
/dev/loop2 256M 256M 0 100% /snap/gnome-3-34-1804/36
/dev/loop3 218M 218M 0 100% /snap/gnome-3-34-1804/60
/dev/loop4 63M 63M 0 100% /snap/gtk-common-themes/1506
/dev/loop5 50M 50M 0 100% /snap/snap-store/467
/dev/loop6 51M 51M 0 100% /snap/snap-store/481
/dev/loop7 30M 30M 0 100% /snap/snapd/8542
/dev/loop8 31M 31M 0 100% /snap/snapd/9721
/dev/sda1 511M 4.0K 511M 1% /boot/efi
tmpfs 196M 12K 196M 1% /run/user/125
tmpfs 196M 36K 196M 1% /run/user/1000
192.168.6.119:/home/test 16G 6.8G 7.5G 48% /mnt/test
192.168.6.119:/home/test2 16G 6.8G 7.5G 48% /mnt/test2
After the share folders is mounted then I am enter Into the test directory
root@linuxhelp:~# cd /mnt/test
Inside the test directory I will create some txt files but I cannot create the because the server give only read permission to this directory
root@linuxhelp:/mnt/test# touch test.txt
touch: cannot touch 'test.txt': Read-only file system
Then I am enter into the test2 directory by using cd command
root@linuxhelp:/mnt/test# cd ../test2/
Inside the directory I am create some file on it and the file has been created, here the server can give read and write permission to this folder
root@linuxhelp:/mnt/test2# touch test.txt
Now I am edit the txt file by using vim editor
root@linuxhelp:/mnt/test2# vim test.txt
finally I view the txt file by executing following command
root@linuxhelp:/mnt/test2# cat test.txt
Welcome to LinuxHelp
With this method, the Installation and configuration of NFS on Linux Mint 20 is comes to an end.
exportfs -u - Unexports all shares listed in /etc/exports, or given name
exportfs -a - Exports all shares listed in /etc/exports, or given name
exportfs -v - Displays a list of shares files and options on a server
showmount -d - Lists all the sub directories
showmount -e : Lists the available shares at the remote server
showmount -e - Shows the available shares on your local machine
they were on the user's own computer. The NFS protocol is one of several distributed file system standards for network-attached storage (NAS).
Portmap maps calls from other machines to the correct RPC service (not required with NFSv4).
rpc.mountd service is responsible for mounting and unmounting of file systems.