NFS Server can be used to serve storage to multiple machines. Here’s how you can setup NFS Server on Ubuntu 19.10
Run Aptitude Update and Upgrade first.
huzefa@ubuntu-server:$ sudo apt-get update
huzefa@ubuntu-server:$ sudo apt-get upgrade
Once your system has latest updates installed. Run below apt command to install NFS Server Package.
huzefa@ubuntu-server:$ sudo apt install nfs-kernel-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
nfs-kernel-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 94.5 kB of archives.
After this operation, 367 kB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu eoan/main amd64 nfs-kernel-server amd64 1:1.3.4-2.5ubuntu2 [94.5 kB]
Fetched 94.5 kB in 0s (558 kB/s)
Selecting previously unselected package nfs-kernel-server.
(Reading database ... 267406 files and directories currently installed.)
Preparing to unpack .../nfs-kernel-server_1%3a1.3.4-2.5ubuntu2_amd64.deb ...
Unpacking nfs-kernel-server (1:1.3.4-2.5ubuntu2) ...
Setting up nfs-kernel-server (1:1.3.4-2.5ubuntu2) ...
nfs-server.service is a disabled or a static unit not running, not starting it.
Processing triggers for man-db (2.8.7-3) ...
Processing triggers for systemd (242-7ubuntu3.7) ...
Now make a directory which you want to share over NFS.
huzefa@ubuntu-server:~$ sudo mkdir /nfs-server/
Change permission to 777 in order to make it publically accessible.
huzefa@ubuntu-server:~$ sudo chmod -R 777 /nfs-server/
Now edit /etc/exports file to add nfs rules
huzefa@ubuntu-server:$ sudo gedit /etc/exports
# /etc/exports: the access control list for filesystems which may be exported
# to NFS clients. See exports(5).
#
# Example for NFSv2 and NFSv3:
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
#
# Example for NFSv4:
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
#
/nfs-server citrix-virt.demunix.com(rw,sync,no_subtree_check)
Start the NFS Service.
huzefa@ubuntu-server:$ sudo systemctl start nfs-kernel-server.service
Export configuration.
huzefa@ubuntu-server:$ sudo exportfs -a
On a client (machine where you want to attach this nfs) (This machine must have nfs client installed)
Make a directory to mount the nfs mountpoint.
[root@citrix-virt /]# mkdir /shared-from-nfs
Mount the NFS shared mountpoint to above created directory.
[root@citrix-virt /]# mount -t nfs ubuntu-server:/nfs-server /shared-from-nfs/
Verify using df -h command.
[root@citrix-virt /]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 512M 20K 512M 1% /dev
tmpfs 524M 240K 524M 1% /dev/shm
tmpfs 524M 7.5M 516M 2% /run
tmpfs 524M 0 524M 0% /sys/fs/cgroup
/dev/sda1 18G 1.8G 15G 11% /
xenstore 524M 0 524M 0% /var/lib/xenstored
/dev/sda4 512M 2.0M 510M 1% /boot/efi
/dev/sda5 3.9G 24M 3.6G 1% /var/log
tmpfs 105M 0 105M 0% /run/user/0
ubuntu-server:/nfs-server 915G 326G 543G 38% /shared-from-nfs
Navigate to /shared-from-nfs directory and verify it’s content.
[root@citrix-virt /]# cd /shared-from-nfs/
[root@citrix-virt shared-from-nfs]# ll
total 24265780
-rw-r--r-- 1 1000 130 4072669184 Feb 14 00:35 OL6-10.iso
-rw-rw-r-- 1 1000 130 4440719360 Aug 28 2019 OL7-5_64.iso
-rw-rw-r-- 1 1000 130 7105150976 Oct 12 20:48 OL8_64.iso
-rw-rw-r-- 1 1000 130 7103053824 Oct 12 00:27 RHEL8_64.iso
-rw-r--r-- 1 1000 130 2126544896 Feb 15 01:12 ubuntu-18.04.4-desktop-amd64.iso
There you go. Peace 🙂