Samba: Mounting in Linux

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

File manager mounting:

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

Command line mounting:

http://ubuntuforums.org/showthread.php?t=1658828
http://www.justlinux.com/nhf/Filesystems/Mounting_smbfs_Shares_Permanently.html

  • 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:

http://ubuntuforums.org/showthread.php?t=1409720
http://askubuntu.com/questions/157128/proper-fstab-entry-to-mount-a-samba-share-on-boot
https://wiki.ubuntu.com/MountWindowsSharesPermanently

  • 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:
    username=<username>
    password=<password>
  • 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>