The advantage of a cifs mount is that it is does not depend on the File Manger / gvfs or any samba client processes since it is Linux Kernel based.
The best approach would be to do a manual mount first to settle on the desired set of options then set it up in fstab to have it mount automatically.
Note: Make sure a cifs "helper" utility is installed:
Code: Select all
sudo apt install cifs-utils
sudo mount -t cifs //server/share /mountpoint -o comma,seperated,list,of,options
server can be expressed as:
hostname = least reliable since cifs has no idea what a NetBIOS name is.
hostname.local = more reliable but the server must be running Linux, Win10, MacOS, or any network device designed for MacOS
ip-address = most reliable but the server must have a static ip address
/mountpoint has some consequences associated with it:
Under /media or in your home directory it will create mount icons on your desktop if your desktop allows it and on the side panel of your file manager. It can also interfere with a systemd automount should you decide to use that ( explained below ).
Under /mnt and it will do none of that. For the most part this is the desired location.
What follows is a list of use cases:
** Access a server as a guest user:
sudo mount -t cifs //server/share /mountpoint -o guest
Depending on what OS the server is running and how it is set up you will likely end up with a share that is writeable only to root.
You could replace root with your primary user by adding a uid=your-name:
sudo mount -t cifs //server/share /mountpoint -o guest,uid=altair
It will be readable to everyone on your system but writeable only to altair.
You can make it so it is writeable to every local user:
Code: Select all
sudo mount -t cifs //server/share /mountpoint -o guest,uid=altair,nounix,dir_mode=0777,file_mode=0666
Code: Select all
sudo mount -t cifs //server/share /mountpoint -o guest,uid=altair,gid=plugdev,nounix,dir_mode=0775,file_mode=0664
** Accessing a server with credentials ( user name and password ):
Code: Select all
sudo mount -t cifs //server/share /mountpoint -o username=altair,password=altairpw,uid=altair
## Create a file at /etc/samba/credentials
## With the credentials one item per line:
username=altair
password=altairpw
Then the line would be:
Code: Select all
sudo mount -t cifs //server/share /mountpoint -o credentials=/etc/samba/credentials,uid=altair
SMB Dialects:
SMB dialects are not versions of samba or CIFS. They are the underlying protocol of the SMB system. CIFS automatically negotiates with the server on first contact the best smb dialect to use starting from SMB2.1 all the way up to SMB3.11.
If you have a server that can only be accessed by SMB1 or SMB2.0 cifs cannot make a connection. But you can override this limitation with the vers option:
SMB1 : vers=1.0
SMB2 : vers=2.0
NOTE: As of Linux Kernel 5.15 ( Mint 21 ) the sec=ntlm option is no longer available. If your device requires it and upgrading it to more current standards is not possible you are out of luck.
Atutomount in /etc/fstab:There is also the issue of security mode. By default cifs uses a security mode which is standard on all current operating systems. But if your server requires something earlier it can be set with this option:
sec=ntlm
So a manual mount of a guest accessible server that uses only SMB1 and requires a lower security level would look like this:
sudo mount -t cifs //server/share /mountpoint -o guest,uid=altair,vers=1.0,sec=ntlm
Once you find the manual mount settings that are successful you can add a declaration to have it automount in /etc/fstab - but with a syntax change. I will use the one that allows everyone write access:
Code: Select all
//server/share /mountpoint cifs guest,uid=altair,nounix,dir_mode=0777,file_mode=0666,nofail 0 0
There are two approaches to remedy this:
[1] You can set the mountpoint under /media ( or your home directory ) and add
noauto,user
and end up with links on the side panel of your File Manager that are "actionable" to an ordinary user - click on it and it will mount. Click or right click it again and it will unmount:
Code: Select all
//server/share /media/mountpoint cifs guest,uid=altair,nounix,noauto,user,dir_mode=0777,file_mode=0666 0 0
[2] You can also do a systemd automount.
In this case I will create the mount point under /mnt:
Code: Select all
//server/share /mnt/mountpoint cifs guest,uid=altair,nounix,noauto,x-systemd.automount,dir_mode=0777,file_mode=0666 0 0
x-systemd.idle-timeout=300
== System will unmount share if idle for 300 seconds.You then have to make systemd happy by running the following commands:
Code: Select all
sudo systemctl daemon-reload
sudo systemctl restart remote-fs.target
Note: Mount points under /media or your home directory when using a systemd.automount do not play well together. Udisks2 interferes with this process and will automount at login regardless of the noauto option. That is why it it would be best to have the mount point under /mnt.