The Quick and Easy way to mount an SMB share on Debian based distros
Linux based OS’s can feel overwhelmingly complicated at the best of times, let along having to mount a network share, so the last thing you want to do is to have to re-mount it manually after ever single reboot. The simplest method to do just that is to add an entry in into fstab (File System Table) which has the very job of controlling what partitions and/or shares are to be mounted on boot.
The fstab configuration file is stored in the /etc directory, so lets open the configuration file in your favourite text editor. In this example we’ll use nano.
sudo nano /etc/fstab
Lets first look at the syntax to be added as a new line in the fstab configuration file to connect to an smb share.
//<IP ADDRESS>/<SHARED_FOLDER> /mnt/<LOCAL_FOLDER> cifs username=<USERNAME>,password=<PASSWORD> 0 0
<IP ADDRESS> – This is the IP address of the host sharing the SMB/CIFS share
<SHARED FOLDER> – The shared folder name
<LOCAL FOLDER> – What you want to call the share when mapped locally on the linux system. It does have to be inside the /mnt folder, but this is simply convention.
<USERNAME> – Username that has permissions to access the share
<PASSWORD> – Password for the above user
0 0 – Just leave these at their default 0 0, as the functionalty of these options are beyond the scope of this post.
//192.168.1.123/plex_media /mnt/plex_media cifs username=plex_user,password=pl3X 0 0
It’s worth noting, that mounting a share in this way does not deal well with shared folders that have spaces in their name. To deal with this, you need to use a special character combination of “\040”. So if we take the above example again, but the shared folder is actually “plex media”, the configuration in fstab would be as follows.
//192.168.1.123/plex\040media /mnt/plex_media cifs username=plex_user,password=pl3X 0 0
