022015

Methods for Mounting Samba Shares Andrew Mallett | Posted February 2015

The Samba software suite is a collection of programs that implements the Server Message Block (commonly abbreviated as SMB) protocol for UNIX systems. This protocol is sometimes also referred to as the Common Internet File System (CIFS) and allows other systems such as Windows and Android to connect to shared directories.

There are a number of ways to mount samba shares. In the following examples sharename is the name of the shared directory on the remote Samba server and mountpoint is the name of the local directory which the remote share will be mounted to. Variations on the method are also included and may need to be experimented with.

Note that Linux Mint and similar distros have dropped smbmount support in favour of CIFS. See installing cifs instead of smbmount.

 

Listing a shared directory

smbclient -L ipaddress -U username

smbclient //ipaddress/sharename -U username

 

Mounting an SMB share using the smbmount command

smbmount //ipaddress/sharename /mountpoint -o username=name,workgroup=name

 

Mounting an SMB share using the mount command

mount -t smbfs ipaddress:/sharename /mountpoint -o username=name,workgroup=name

mount -t smbfs //ipaddress/sharename /mountpoint -o username=name,workgroup=name

 

Mounting an SMB share using the mount cifs command

mount -t cifs ipaddress:/sharename /mountpoint -o username=name,workgroup=name

 

Mounting an SMB share including the password

mount -t smbfs -o username=name,workgroup=name,password=pwd //ipaddress/sharename /mountpoint

 

Mounting an SMB share by editing fstab

vi /etc/fstab//ipaddress/sharename /mountpoint smbfs rw,user,username=name,password=pwd 0 0

Save and exit the file and then confirm the mount using the following commands..

mount -a

df -H

If the systems are running on a Domain, use the domain user's username and password.

Note that this method raises security concerns due to fstab being readable by all users. A workaround is to put an .smbfile in the user's own home directory containing their username and password.

cd ~
echo username=name > .smbfile
echo password=passwd >> .smbfile
chmod 600 .smbfile 

Then run the command to point to the .smbfile for the user credentials..

vi /etc/fstab //ipaddress/sharename /mountpoint smbfs credentials=/home/userhomedir/. smbfile,rw,user 0 0 

 

Mounting without a passsword prompt using mount_smbfs

It's not over yet! Another variation on the above uses mount_smbfs to mount a password-protected samba share without being prompted for a password. This is useful for automated scripts. See Mount Samba Shares Without a password Prompt.

 

UnMounting shares

Piece of piss, mate..

umount /mountpointdirname

Sharing files using NFS

The Network File System provides a way to share directories under Unix operating systems in a similar way to Samba. See File Sharing with NFS on Linux.

 

 

Back

Comments (3)

Network shares
Youve left out a very improtant method - NFS.
#1 - Monobyte_77 - 02/03/2015 - 00:26
NFS
No worries, I've added a link to using NFS :-D
#2 - AndyM - 02/06/2015 - 10:50
Shares
Different versions of Linux seem to have diferent ways of doing this. Its useful to have them all listed so you can try out different ways.
#3 - Burnside - 04/04/2015 - 22:26
Name
E-mail (Will not appear online)
Homepage
Title
Comment
;-) :-) :-D :-( :-o :-O B-) :oops: :-[] :-P
To prevent automated Bots form spamming, please enter the text you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
»
This comment form is powered by GentleSource Comment Script. It can be included in PHP or HTML files and allows visitors to leave comments on the website.

Disposable Email   Temporary Email   Throwaway Email