Bookmark this page

Lab: Access Network-Attached Storage

Configure the automounter with an indirect map, using exports from an NFSv4 server.

Outcomes

  • Install required packages to set up the automounter.

  • Configure an automounter indirect map, with resources from a preconfigured NFSv4 server.

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

This start script determines whether the servera and serverb systems are reachable on the network. The start script configures serverb as an NFSv4 server, sets up permissions, and exports directories. The script also creates users and groups that are needed on both servera and serverb systems.

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

Instructions

An IT support company uses a central server, serverb, to host some exported directories on /shares for their groups and users. Users must be able to log in and have their exported directories mounted on demand and ready to use, in the /remote directory on servera.

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

  • The serverb machine is sharing the /shares directory, which in turn contains the management, production, and operation subdirectories.

  • The managers group consists of the manager1 and manager2 users. Those users have read and write access to the /shares/management exported directory.

  • The production group consists of the dbuser1 and sysadmin1 users. Those users have read and write access to the /shares/production exported directory.

  • The operators group consists of the contractor1 and consultant1 users. Those users have read and write access to the /shares/operation exported directory.

  • The main mount point for servera is the /remote directory.

  • Use the /etc/auto.master.d/shares.autofs file as the master map file, and use the /etc/auto.shares file as the indirect map file.

  • The /shares/management exported directory is automounted on /remote/management on servera.

  • The /shares/production exported directory is automounted on /remote/production on servera.

  • The /shares/operation exported directory is automounted on /remote/operation on servera.

  • All user passwords are set to redhat.

  1. Log in to servera and install the required packages.

    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. Install the autofs package.

      [root@servera ~]# dnf install autofs
      ...output omitted...
      Is this ok [y/N]: y
      ...output omitted...
      Complete!
  2. Configure an automounter indirect map on servera with exports from serverb. Create an indirect map with files that are named /etc/auto.master.d/shares.autofs for the master map and /etc/auto.shares for the mapping file. Use the /remote directory as the main mount point on servera. Reboot servera to determine whether the autofs service starts automatically.

    1. Test the NFS server before you configure the automounter.

      [root@servera ~]# mount -t nfs serverb.lab.example.com:/shares /mnt
      [root@servera ~]# ls -l /mnt
      total 0
      drwxrwx---. 2 root managers   25 Apr  4 01:13 management
      drwxrwx---. 2 root operators  25 Apr  4 01:13 operation
      drwxrwx---. 2 root production 25 Apr  4 01:13 production
      [root@servera ~]# umount /mnt
    2. Create a master map file named /etc/auto.master.d/shares.autofs, insert the following content, and save the changes.

      /remote	/etc/auto.shares
    3. Create an indirect map file named /etc/auto.shares, insert the following content, and save the changes.

      * -rw,sync,fstype=nfs4 serverb.lab.example.com:/shares/&
    4. Start and enable the autofs service on servera.

      [root@servera ~]# systemctl enable --now autofs
      Created symlink /etc/systemd/system/multi-user.target.wants/autofs.service → /usr/lib/systemd/system/autofs.service.
  3. Test the autofs configuration with the various users. When done, log out from servera.

    1. Switch to the manager1 user and test access.

      [root@servera ~]# su - manager1
      [manager1@servera ~]$ ls -l /remote/management/
      total 4
      -rw-r--r--. 1 root managers 46 Apr  4 01:13 Welcome.txt
      [manager1@servera ~]$ cat /remote/management/Welcome.txt
      ###Welcome to Management Folder on SERVERB###
      [manager1@servera ~]$ echo TEST1 > /remote/management/Test.txt
      [manager1@servera ~]$ cat /remote/management/Test.txt
      TEST1
      [manager1@servera ~]$ ls -l /remote/operation/
      ls: cannot open directory '/remote/operation/': Permission denied
      [manager1@servera ~]$ ls -l /remote/production/
      ls: cannot open directory '/remote/production/': Permission denied
      [manager1@servera ~]$ exit
      logout
      [root@servera ~]#
    2. Switch to the dbuser1 user and test access.

      [root@servera ~]# su - dbuser1
      [dbuser1@servera ~]$ ls -l /remote/production/
      total 4
      -rw-r--r--. 1 root production 46 Apr  4 01:13 Welcome.txt
      [dbuser1@servera ~]$ cat /remote/production/Welcome.txt
      ###Welcome to Production Folder on SERVERB###
      [dbuser1@servera ~]$ echo TEST2 > /remote/production/Test.txt
      [dbuser1@servera ~]$ cat /remote/production/Test.txt
      TEST2
      [dbuser1@servera ~]$ ls -l /remote/operation/
      ls: cannot open directory '/remote/operation/': Permission denied
      [dbuser1@servera ~]$ ls -l /remote/management/
      ls: cannot open directory '/remote/management/': Permission denied
      [dbuser1@servera ~]$ exit
      logout
      [root@servera ~]#
    3. Switch to the contractor1 user and test access.

      [root@servera ~]# su - contractor1
      [contractor1@servera ~]$ ls -l /remote/operation/
      total 4
      -rw-r--r--. 1 root operators 45 Apr  4 01:13 Welcome.txt
      [contractor1@servera ~]$ cat /remote/operation/Welcome.txt
      ###Welcome to Operation Folder on SERVERB###
      [contractor1@servera ~]$ echo TEST3 > /remote/operation/Test.txt
      [contractor1@servera ~]$ cat /remote/operation/Test.txt
      TEST3
      [contractor1@servera ~]$ ls -l /remote/management/
      ls: cannot open directory '/remote/management/': Permission denied
      [contractor1@servera ~]$ ls -l /remote/production/
      ls: cannot open directory '/remote/production/': Permission denied
      [contractor1@servera ~]$ exit
      logout
      [root@servera ~]#
    4. Explore the mount options for the NFS automounted export.

      [root@servera ~]# mount | grep nfs
      rpc_pipefs on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
      serverb.lab.example.com:/shares/management on /remote/management 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)
      serverb.lab.example.com:/shares/operation on /remote/operation 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)
      serverb.lab.example.com:/shares/production on /remote/production 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. Return to the workstation machine as the student user.

      [root@servera ~]# exit
      logout
      [student@servera ~]$ exit
      logout
      Connection to servera closed.

Evaluation

On the workstation machine, use the lab command to confirm success of this exercise.

[student@workstation ~]$ lab grade netstorage-review

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-review

Revision: rh134-9.3-5fd2368