Bookmark this page

Guided Exercise: Mounting a SMB File System

In this lab, you will create a mount entry in /etc/fstab and mount it.

Resources:
Files: samba.txt in the server directory, for testing.
Machines: desktopX and serverX

Outcomes

  • cifs-utils package installed.

  • The serverX student home folder mounted at /home/student/work.

  • The /etc/fstab file includes the mount entry.

  • Reset your serverX system.

  • Log into and set up your server system.

    [student@serverX ~]$ lab samba setup
  • Reset your desktopX system.

  • Log into desktopX and open a terminal.

You have a home directory on serverX that is used to store work-related documents. The directory is shared via Samba to support all of the company desktop operating systems.

The serverX administrator has confirmed that the share name is student and that the uid/gid are the same as your desktopX instance; the share password is student.

  1. Install the Package

    Use yum to install cifs-utils.

    [student@desktopX ~]$ sudo yum -y install cifs-utils
    Loaded plugins: langpacks
    Resolving Dependencies
    ...
    Complete!

    This package provides support for mounting CIFS file systems and is used by the mount command.

  2. Create the Mount Point

    Use mkdir to create the work directory mount point.

    [student@desktopX ~]$ mkdir ~/work
  3. Create the Credentials File

    1. Use mkdir to create the secure directory.

      [student@desktopX ~]$ sudo mkdir /secure
    2. Use vim to create the credentials file student.smb and populate it.

      [student@desktopX ~]$ sudo vim /secure/student.smb

      Add the following lines:

      username=student
      password=student
      domain=MYGROUP
    3. Use chmod to protect the secure directory and the student.smb credentials file.

      [student@desktopX ~]$ sudo chmod 770 /secure
      [student@desktopX ~]$ sudo chmod 600 /secure/student.smb
  4. Update /etc/fstab and Mount

    1. Use vim to add the mount settings to the end of /etc/fstab.

      [student@desktopX ~]$ sudo vim /etc/fstab
      ...
      //serverX/student  /home/student/work  cifs  credentials=/secure/student.smb  0 0
    2. Use mount to verify the settings and mount the file system.

      [student@desktopX ~]$ sudo mount -a

      This command should report no errors. If it does, check your settings in /etc/fstab.

  5. Check Your Access

    1. Use cat to output the samba.txt file.

      [student@desktopX ~]$ cat ~/work/samba.txt
      Success
    2. Use echo to write to the work mount point.

      [student@desktopX ~]$ echo testing > ~/work/test.txt
Revision: rh199-7-d0984a3