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.

[[email protected] ~]# dnf -y install nfs-utils
[[email protected] ~]# vi /etc/idmapd.conf

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

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

[[email protected] ~]# mount -t nfs ns1.futurelinux.org:/home /home
[[email protected] ~]# 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
[[email protected] ~]# mount -t nfs -o vers=3 ns1.futurelinux.org:/home /home
[[email protected] ~]# 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.

[[email protected] ~]# 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.

[[email protected] ~]# dnf install autofs -y
[[email protected] ~]# vi /etc/auto.master

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

[[email protected] ~]# vi /etc/auto.mount

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

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

[[email protected] ~]# 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