Skip to content

Home Lab

Notes from my learning sessions

Menu
Menu

Installing NFS Server

Posted on September 27, 2021October 11, 2021 by sandeep

The objective is to configure the NFS server on one of the servers in the LAB.

Creating the NFS client-server setup is a simple task that can be performed in a few steps – installation, export, mounting, and access.

On the server install the required package

apt install -y nfs-kernel-server

Create a directory that gets shared with the clients.

mkdir /mnt/nfs

To allow all clients access permission to the export directory, we need to remove restrictive permissions.

chown nobody:nogroup /mnt/nfs
chmod 755 /mnt/nfs

Create the NFS server configuration file /etc/exports, with contents as below, configuration for sharing the shared folder created above. In my case wanted to share with clients from two different subnets.

# /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)
#
/mnt/nfs 10.0.1.0/24(rw,sync,no_subtree_check)
/mnt/nfs 10.0.2.0/24(rw,sync,no_subtree_check)
Note :   
    rw:                read and write operations
    sync:              write any change to the disc before applying it
    no_subtree_check:  no subtree checking 

Export the shared directory listed in /etc/exports

exportfs -a

On the client’s side install the required package

apt-get install nfs-common 

Create a folder to be used as a mount point to mount the shared NFS folder

mkdir -p /mnt/nfs

Mount the shared folder

mount 10.0.1.1:/mnt/nfs /mnt/nfs

We need to mount this folder every time the VM starts – Add the following entry in /etc/fstab as follows

root@test:~# cat /etc/fstab
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# systemd generates mount units based on this file, see systemd.mount(5).
# Please run 'systemctl daemon-reload' after making changes here.
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/vda1 during installation
UUID=e8272e4a-5782-4500-9e91-2bfe3c9da8fd /               ext4    errors=remount-ro            0       1
# swap was on /dev/vda5 during installation
UUID=f0f2cd7b-2c15-4bde-a3dc-ab2e1653ec56 none            swap    sw                           0       0
/dev/sr0                                  /media/cdrom0   udf,iso9660 user,noauto              0       0
10.0.1.1:/mnt/nfs                         /mnt/nfs        nfs4    defaults,user,exec,_netdev   0       0
root@test:~#

Recent Posts

  • Ceph + KVM: 4. Orchestrating Ceph RBD backed VMs on KVM Hosts
  • Rabbit MQ Cluster + HAProxy + Keepalived
  • Install and configure MariaDB / Galera cluster
  • Ceph + KVM : 3. Installing KVM, cutsomized monitoring scripts
  • Ceph + KVM : 5. Service checks and CLI commands
  • Ceph + KVM : 2. Installation – Ceph Storage
  • Ceph + KVM : 1. Planning and preparing for Ceph Storage
  • Openstack Xena on Ubuntu 20.04 – Cinder
  • Preparing custom Debian 11 MATE image
  • Setup Ubuntu 20.04 repository mirror server

Archives

  • April 2025
  • March 2025
  • October 2024
  • September 2024
  • April 2022
  • March 2022
  • February 2022
  • December 2021
  • October 2021
  • September 2021
  • October 2020
  • February 2020
  • January 2020
  • December 2019
© 2025 Home Lab | Powered by Minimalist Blog WordPress Theme