Bookmark this page

Chapter 14. Mounting Network File Systems

Abstract

Goal To use autofs and the command line to mount and unmount network storage with NFS and SMB.
Objectives

  • Mount, access, and unmount network storage with NFS.

  • Automount and access network storage with NFS.

  • Mount, automount, and unmount SMB file systems.

Sections
  • Mounting Network Storage with NFS (and Practice)

  • Automounting Network Storage with NFS (and Practice)

  • Accessing Network Storage with SMB (and Practice)

Lab
  • Accessing Network Storage with Network File System (NFS)

  • Accessing Network Storage with SMB

Mounting Network Storage with NFS

  • Identify the NFS share details; NFSv4 mount the NFS server root folder.

  • Create a mount point directory.

  • mount or update /etc/fstab to mount the NFS share.

  • umount to unmount a NFS share.

Objectives

After completing this section, students should be able to manually mount, access, and unmount an NFS share.

Manually mounting and unmounting NFS shares

NFS, the Network File System, is an Internet standard protocol used by Linux, UNIX, and similar operating systems as their native network file system. It is an open standard under active extension which supports native Linux permissions and file system features.

Red Hat Enterprise Linux 7 supports NFSv4 (version 4 of the protocol) by default, and falls back automatically to NFSv3 and NFSv2 if that is not available. NFSv4 uses the TCP protocol to communicate with the server, while older versions of NFS may use either TCP or UDP.

NFS servers export shares (directories) and NFS clients mount an exported share to a local mount point (directory). The local mount point must exist. NFS shares can be mounted a number of ways:

  • manually mounting an NFS share using the mount command.

  • automatically mounting an NFS share at boot time using /etc/fstab.

  • mounting an NFS share on demand through a process known as automounting.

Securing file access on NFS shares

NFS servers secure access to files using a number of methods: none, sys, krb5, krb5i, and krb5p. The NFS server can choose to offer a single method or multiple methods for each exported share. NFS clients must connect to the exported share using one of the methods mandated for that share, specified as a mount option sec=method.

Security methods

  • none: anonymous access to the files, writes to the server (if allowed) will be allocated UID and GID of nfsnobody.

  • sys: file access based on standard Linux file permissions for UID and GID values. If not specified, this is the default.

  • krb5: Clients must prove identity using Kerberos and then standard Linux file permissions apply.

  • krb5i: adds a cryptographically strong guarantee that the data in each request has not been tampered with.

  • krb5p: adds encryption to all requests between the client and the server, preventing data exposure on the network. This will have a performance impact.

Important

Kerberos options will require, as a minimum, a /etc/krb5.keytab and additional authentication configuration that is not covered in this section (joining the Kerberos Realm). The /etc/krb5.keytab will normally be provided by the authentication or security administrator. Request a keytab that includes either a host principal, nfs principal, or (ideally) both.

NFS uses the nfs-secure service to help negotiate and manage communication with the server when connecting to Kerberos-secured shares. It must be running to use the secured NFS shares; start and enable it to ensure it is always available.

[student@desktopX ~]$ sudo systemctl enable nfs-secure
ln -s '/usr/lib/systemd/system/nfs-secure.service'  ...
[student@desktopX ~]$ sudo systemctl start nfs-secure

Note

The nfs-secure service is part of the nfs-utils package, which should be installed by default. If it is not installed, use:

[student@desktopX ~]$ sudo yum -y install nfs-utils

Mount an NFS share

There are three basic steps to mounting an NFS share:

  1. Identify: The administrator for the NFS server can provide export details, including security requirements. Alternatively:

    NFSv4 shares can be identified by mounting the root folder of the NFS server and exploring the exported directories. Do this as root. Access to shares that are using Kerberos security will be denied, but the share (directory) name will be visible. Other share directories will be browsable.

    [student@desktopX ~]$ sudo mkdir /mountpoint
    [student@desktopX ~]$ sudo mount serverX:/ /mountpoint
    [student@desktopX ~]$ sudo ls /mountpoint

    NFSv2 and NFSv3 shares can be discovered using showmount.

    [student@desktopX ~]$ showmount -e serverX
  2. Mount point: Use mkdir to create a mount point in a suitable location.

    [student@desktopX ~]$ mkdir -p /mountpoint
  3. Mount: There are two choices here: manually or incorporated in the /etc/fstab file. Switch to root or use sudo for either operation.

    • Manual: Use the mount command.

      [student@desktopX ~]$ sudo mount -t nfs -o sync serverX:/share /mountpoint

      The -t nfs option is the file system type for NFS shares (not strictly required, shown for completeness). The -o sync option tells mount to immediately synchronize write operations with the NFS server (the default is asynchronous). The default security method (sec=sys) will be used to try mounting the NFS share, using standard Linux file permissions.

    • /etc/fstab: Use vim to edit the /etc/fstab file and add the mount entry to the bottom of the file. The NFS share will be mounted at each system boot.

      [student@desktopX ~]$ sudo vim /etc/fstab
      ...
      serverX:/share  /mountpoint  nfs  sync  0 0

Use umount, using root privileges, to manually unmount the share.

[student@desktopX ~]$ sudo umount /mountpoint

References

mount(8), umount(8), fstab(5), and mount.nfs(8) man pages

Revision: rh199-7-d0984a3