Mount an SMB File Share on Linux.

Brian Kepha
2 min readFeb 16, 2024

--

SMB is an abbreviation for Server Message Block which is a Storage Protocol that provides sharing capabilities for directories over a network. SMB protocol is commonly used for Windows Files Share. SMB protocol was Developed by IBM but is currently maintained by Microsoft hence why it used mostly for Microsoft Network Share.

Mounting SMB file share on Windows is as simple as copying the Share link and pasting it in the Windows Explorer link tab.It is however different on Linux. Let’s see how it’s done.

Chances are that your Linux doesn’t come with SMB Support out of the box.So you probably got to install SMB Support. Let’s install it.

Installation

On Debian, Ubuntu and their downstream equivalent, this is how you install SMB.

  1. Update the list of available packages using the below command:
sudo apt update && sudo apt upgrade

2. Install the CIFS client by using the apt package manager.

sudo apt install cifs-utils

3. Verify that LinuxCIFS is available using the following command.No error means you are good as there are no CIFS connections YET.

mount  -t  cifs

Mount an SMB Share

  1. Create an empty directory which will be your mount point. e.g
mkdir   /mnt/smb

2. Enter the following command to mount the SMB share, replacing [server-ip] with the IP address of your SMB server, [share-path] with the file path to your SMB share on that server, and [mount-point] with the new directory you just created.

mount -t cifs //[server-ip]/[share-path] /[mount-point]

e.g

sudo mount -t cifs //192.168.100.1/myshare /mnt/smb

After the mount, you can move into the directory and list the files , create more files and even use the files for your Application needs.

You can also check how much storage volume is occupied by your network share using the command

df -h

Now you can do the mount with a bunch of other options and flags if you really need to but not necessary unless you know your stuff e.g For example if you want to pass your credentials files , you can use the flag

 -o credentials 

The command would look something like this with options to specify read and write buffer sizes. For more information on mount options look here.

sudo mount -t cifs //192.168.100.1/myshare /mnt/smb -o vers=2.0,guest,uid=0,gid=0,dir_mode=0755,file_mode=0755,mfsymlinks,cache=strict,rsize=1048576,wsize=1048576

The aim of this article was to be short and to the point hence I shall stop there. Follow me for more.

--

--