Bookmark this page

Guided Exercise: Manage Network-Attached Storage with NFS

Modify the /etc/fstab file to persistently mount an NFS export at boot time.

Outcomes

  • Test an NFS server with the mount command.

  • Configure NFS exports in the /etc/fstab configuration file to save changes even after a system reboots.

As the student user on the workstation machine, use the lab command to prepare your system for this exercise.

This command prepares your environment and ensures that all required resources are available.

[student@workstation ~]$ lab start netstorage-nfs

Instructions

A shipping company uses a central NFS server, serverb, to host various exported documents and directories. Users on servera, who are all members of the admin group, need access to the persistently mounted NFS export.

The following list provides the environment characteristics for completing this exercise:

  • The serverb machine exports the /shares/public directory, which contains some text files.

  • Members of the admin group (admin1, sysmanager1) have read and write access to the /shares/public exported directory.

  • The mount point on servera must be the /public directory.

  • All user passwords are set to redhat.

  • The nfs-utils package is already installed.

  1. Log in to servera as the student user and switch to the root user.

    1. Log in to servera as the student user and switch to the root user.

      [student@workstation ~]$ ssh student@servera
      ...output omitted...
      [student@servera ~]$ sudo -i
      [sudo] password for student: student
      [root@servera ~]#
  2. Test the NFS server on serverb with servera as the NFS client.

    1. Create the /public mount point on the servera machine.

      [root@servera ~]# mkdir /public
    2. On servera, verify that the /shares/public NFS export from serverb successfully mounts to the /public directory.

      [root@servera ~]# mount -t nfs \
      serverb.lab.example.com:/shares/public /public
    3. List the contents of the mounted NFS export.

      [root@servera ~]# ls -l /public
      total 16
      -rw-r--r--. 1 root admin 42 Apr  8 22:36 Delivered.txt
      -rw-r--r--. 1 root admin 46 Apr  8 22:36 NOTES.txt
      -rw-r--r--. 1 root admin 20 Apr  8 22:36 README.txt
      -rw-r--r--. 1 root admin 27 Apr  8 22:36 Trackings.txt
    4. Explore the mount command options for the mounted NFS export.

      [root@servera ~]# mount | grep public
      serverb.lab.example.com:/shares/public on /public type nfs4
      (rw,relatime,vers=4.2,rsize=262144,wsize=262144,namlen=255,sync
      ,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=172.25.250.10,
      local_lock=none,addr=172.25.250.11)
    5. Unmount the NFS export.

      [root@servera ~]# umount /public
  3. Configure servera so that the /shares/public export is persistently mounted.

    1. Edit the /etc/fstab file.

      [root@servera ~]# vim /etc/fstab

      Add the following line to the end of the file:

      serverb.lab.example.com:/shares/public  /public  nfs  rw,sync  0 0
    2. Mount the exported directory.

      [root@servera ~]# mount /public
    3. List the contents of the exported directory.

      [root@servera ~]# ls -l /public
      total 16
      -rw-r--r--. 1 root   admin 42 Apr  8 22:36 Delivered.txt
      -rw-r--r--. 1 root   admin 46 Apr  8 22:36 NOTES.txt
      -rw-r--r--. 1 root   admin 20 Apr  8 22:36 README.txt
      -rw-r--r--. 1 root   admin 27 Apr  8 22:36 Trackings.txt
    4. Reboot the servera machine.

      [root@servera ~]# systemctl reboot
  4. After servera is finished rebooting, log in to servera as the admin1 user and test the persistently mounted NFS export.

    1. Log in to servera as the admin1 user.

      [student@workstation ~]$ ssh admin1@servera
      [admin1@servera ~]$
    2. Test the NFS export that is mounted on the /public directory.

      [admin1@servera ~]$ ls -l /public
      total 16
      -rw-r--r--. 1 root   admin 42 Apr  8 22:36 Delivered.txt
      -rw-r--r--. 1 root   admin 46 Apr  8 22:36 NOTES.txt
      -rw-r--r--. 1 root   admin 20 Apr  8 22:36 README.txt
      -rw-r--r--. 1 root   admin 27 Apr  8 22:36 Trackings.txt
      [admin1@servera ~]$ cat /public/NOTES.txt
      ###In this file you can log all your notes###
      [admin1@servera ~]$ echo "This is a test" > /public/Test.txt
      [admin1@servera ~]$ cat /public/Test.txt
      This is a test
    3. Return to the workstation machine as the student user.

      [admin1@servera ~]$ exit
      logout
      Connection to servera closed.

Finish

On the workstation machine, change to the student user home directory and use the lab command to complete this exercise. This step is important to ensure that resources from previous exercises do not impact upcoming exercises.

[student@workstation ~]$ lab finish netstorage-nfs

Revision: rh199-9.3-8dd73db