Samba: Mounting in Linux

Submitted by fmadmin on Fri, 11/18/2016 - 21:59

File manager mounting:

  • File manager > Network: browse to share:
  • Enter the authentication info and check Remember forever
Tip: This can also be saved as a bookmark

Command line mounting:

  • On the Samba server, add client user details
  • On the client system:
    1. Install smbf:
      # apt-get install smbfs
    2. Create directory to mount the SMB share:
      # mkdir /mnt/shares
  • Follow one of the steps below (one-time mount or permanent mount)

One-time mount (will be gone on reboot):

Option A:

# mount -t smbfs //<server>/<share> /<mountpoint> -o username=<username>,password=<password>

Option B:

# smbmount //<server>/<share> /<mountpoint> -o username=<username>,password=<password>

To dismount:

  • # umount /<mountpoint>

To add permanently:

  • Install CIFS:
    # apt-get install cifs-utils
  • Find the uid and gid for fstab entry below:
    # sudo id <user>
  • Open fstab:
    # nano /etc/fstab
    Enter the following:
    //<server>/<share> /<mountpoint> cifs defaults,uid=1000,gid=1000,credentials=/root/.smbcredentials 0 0
    Tip: If above host name is not working, use the IP address
  • Open smbcredentials:
    # nano /root/.smbcredentials
    Enter the following:
  • Change the permissions:
    # chmod 0600 /root/.smbcredentials
  • Create a new directory:
    # mkdir /<mountpoint>
  • Mount the share:
    # mount -a
  • Confirm the share is mounted:
    # ls -l /<mountpoint>