Configure NFS Client

This example is based on the environment below.

NFS Server: ns1.futurelinux.org 192.168.122.2
NFS Client:  ns2.futurelinux.org 192.168.122.3

[1] Install and Configure NFS Client.

[root@ns2 ~]# dnf -y install nfs-utils
[root@ns2 ~]# vi /etc/idmapd.conf

# line 5: uncomment and change to your domain name
Domain = ns2.futurelinux.org

[root@ns2 ~]# systemctl start rpcbind
[root@ns2 ~]# systemctl enable rpcbind
Created symlink /etc/systemd/system/multi-user.target.wants/rpcbind.service β†’ /usr/lib/systemd/system/rpcbind.service.

[root@ns2 ~]# mount -t nfs ns1.futurelinux.org:/home /home
[root@ns2 ~]# df -hT
Filesystem                Type      Size  Used Avail  Use% Mounted on
devtmpfs                  devtmpfs  946M     0  946M    0% /dev
tmpfs                     tmpfs     989M     0  989M    0% /dev/shm
tmpfs                     tmpfs     989M  564K  989M    1% /run
tmpfs                     tmpfs     989M     0  989M    0% /sys/fs/cgroup
/dev/vda1                 ext4       20G  3,7G   15G   20% /
tmpfs                     tmpfs     989M  4,0K  989M    1% /tmp
tmpfs                     tmpfs     198M     0  198M    0% /run/user/0
ns1.futurelinux.org:/home nfs4       20G  3,7G   15G   20% /home
# home directory from NFS server is mounted

# if mount with NFSv3, add [-o vers=3] option
[root@ns2 ~]# mount -t nfs -o vers=3 ns1.futurelinux.org:/home /home
[root@ns2 ~]# df -hT
Filesystem                Type      Size  Used Avail  Use% Mounted on
devtmpfs                  devtmpfs  946M     0  946M    0% /dev
tmpfs                     tmpfs     989M     0  989M    0% /dev/shm
tmpfs                     tmpfs     989M  564K  989M    1% /run
tmpfs                     tmpfs     989M     0  989M    0% /sys/fs/cgroup
/dev/vda1                 ext4       20G  3,7G   15G   20% /
tmpfs                     tmpfs     989M  4,0K  989M    1% /tmp
tmpfs                     tmpfs     198M     0  198M    0% /run/user/0
ns1.futurelinux.org:/home nfs        20G  3,7G   15G   20% /home

[2] Configure NFS mounting on fstab to mount it when the system starts.

[root@ns2 ~]# vi /etc/fstab
/dev/vda1                   /               ext4            defaults                1 1
# add NFS mount's settings to the end
ns1.futurelinux.org:/home   /home           nfs             defaults                0 0

[3] Configure auto-mounting. For example, set NFS directory on /mntdir.

[root@ns2 ~]# dnf install autofs -y
[root@ns2 ~]# vi /etc/auto.master

# add to the end
/-    /etc/auto.mount

[root@ns2 ~]# vi /etc/auto.mount

# create new : [mount point] [option] [location]
/mntdir     -fstype=nfs,rw      ns1.futurelinux.org:/home

[root@ns2 ~]# mkdir -p /mntdir
[root@ns2 ~]# systemctl start autofs
[root@ns2 ~]# systemctl enable autofs
Created symlink /etc/systemd/system/multi-user.target.wants/autofs.service β†’ /usr/lib/systemd/system/autofs.service.

[root@ns2 ~]# cat /proc/mounts | grep mntdir
/etc/auto.mount /mntdir autofs rw,relatime,fd=17,pgrp=2981,timeout=300,minproto=5,maxproto=5,direct,pipe_ino=36873 0 0