Bookmark this page

Guided Exercise: Automounting NFS

In this lab, you will install a package to support automount. Create a direct-map automount and an indirect-map automount using wildcards. serverX is the NFSv4 host.

Resources:
Files: nfs_ldapuserX.txt
Machines: desktopX and serverX

Outcomes

User ldapuserX will be able to successfully log in and use the three automounted directories.

  • Reset the desktopX system.

  • Log into and set up your desktop system.

    [student@desktopX ~]$ lab nfsmount setup
  • Open a terminal.

Important

The serverX setup performed at the beginning of "Mounting and Unmounting NFS" is used for this practice exercise as well. If you have not yet performed the server setup, then run it now. It only needs to be run once for both practice exercises.

S.H.I.E.L.D. (Storage Hardware Incorporating Every Last Document) uses a central server, serverX, to host a number of document share directories. Access to these directories is via LDAP-based users, authenticating using Kerberos with encryption. Users need to be able to log in and have the share directories automount with read and write access, ready for use.

Here are the key details you will need:

  • Username: ldapuserX

  • Password: kerberos

  • serverX is sharing three directories under /shares: docs, work, and public.

  • File access is secured using Kerberos with encryption: krb5p.

  • desktopX mount point: /shares for docs and work and a direct map of public to /mnt/public.

  • The krb5.keytab is available from http://classroom.example.com/pub/keytabs/desktopX.keytab.

  • Each share should have read and write access.

When done with the work, reboot the desktopX machine, then run the command lab nfsmount grade from the desktopX machine to verify the work.

  1. Download and install the krb5.keytab file to enable Kerberos access and security.

    [student@desktopX ~]$ sudo wget -O /etc/krb5.keytab http://classroom.example.com/pub/keytabs/desktopX.keytab
  2. Enable and start the nfs-secure service.

    [student@desktopX ~]$ sudo systemctl enable nfs-secure
    ln -s '/usr/lib/systemd/system/nfs-secure.service'  ...
    [student@desktopX ~]$ sudo systemctl start nfs-secure
  3. Use yum to install autofs, needed for automounting directories.

    [student@desktopX ~]$ sudo yum -y install autofs
    Loaded plugins: langpacks
    Resolving Dependencies
    ...
    Complete!
  4. Create the automount configuration files for the direct-map automount.

    1. Use vim to create and edit the /etc/auto.master.d/direct.autofs file.

      [student@desktopX ~]$ sudo vim /etc/auto.master.d/direct.autofs

      Note: The file extension must be .autofs.

      Add the line as follows:

      /-  /etc/auto.direct
    2. Use vim to create and edit the auto.direct map file.

      [student@desktopX ~]$ sudo vim /etc/auto.direct

      Add the line as follows:

      /mnt/public  -rw,sync,sec=krb5p  serverX:/shares/public

    Note: The file names above are not important; they were chosen to be meaningful.

  5. Create the automount configuration files for the indirect-map automounts.

    1. Use vim to create and edit the /etc/auto.master.d/shares.autofs file.

      [student@desktopX ~]$ sudo vim /etc/auto.master.d/shares.autofs

      Note: The file extension must be .autofs.

      Add the line as follows:

      /shares  /etc/auto.shares
    2. Use vim to create and edit the auto.shares map file.

      [student@desktopX ~]$ sudo vim /etc/auto.shares

      Add the line as follows:

      *  -rw,sync,sec=krb5p  serverX:/shares/&

    Note: The file names above are not important; they were chosen to be meaningful.

  6. Use mkdir to create the /mnt/public mount point for the direct-map automount.

    [student@desktopX ~]$ sudo mkdir -p /mnt/public
  7. Enable and start the automount service.

    [student@desktopX ~]$ sudo systemctl enable autofs
    ln -s '/usr/lib/systemd/system/autofs.service'  ...
    [student@desktopX ~]$ sudo systemctl start autofs
  8. Use ssh to switch to ldapuserX on localhost and confirm the mounts, and read/write access.

    1. Use ssh to log in as ldapuserX.

      [student@desktopX ~]$ ssh ldapuserX@localhost

      If you see something similar to the following, type yes to accept and continue.

      The authenticity of host 'localhost (::1)' can't be established.
      ECDSA key fingerprint is d9:cc:73:82:3b:8a:74:e4:11:2f:f3:2b:03:a4:46:4d.
      Are you sure you want to continue connecting (yes/no)? yes

      Enter the password: kerberos.

      ldapuserX@localhost's password: kerberos
    2. Verify you can switch to the automounted share directories and confirm you have read/write access.

      Use cd to switch directories.

      [ldapuserX@desktopX ~]$ cd /shares/docs

      Use echo and cat to verify read and write access.

      [ldapuserX@desktopX docs]$ echo hello > test.txt
      [ldapuserX@desktopX docs]$ cat test.txt
      hello

      Repeat this step to test /shares/work and /mnt/public.

      Use exit or Ctrl+D to log out of ldapuserX.

  9. Reboot the desktopX machine, then run the command lab nfsmount grade from the desktopX machine to verify the work.

    1. [student@desktopX ~]$ sudo systemctl reboot
    2. [student@desktopX ~]$ lab nfsmount grade
Revision: rh199-7-d0984a3