Automatically Mount Samba Share

Create a directory to mount Samba into mkdir --parents /mnt/my.

Fedora 33 KDE and Kubuntu 20.10

Add the below to /etc/fstab.

//<hostname>/my /mnt/my cifs uid=<username>,gid=users,vers=3.1.1,file_mode=0664,dir_mode=0775,x-systemd.automount,noperm,credentials=/home/<username>/.samba,user 0 0

The credentials file $HOME/.samba should contain credentials as below - set permissions to read-only.

username=value
password=value

You can test the drive mounts at boot, without rebooting, by running the below.

sudo umount -f /mnt/my
sudo systemctl daemon-reload
sudo systemctl restart remote-fs.target

You probably also need to run the below on Fedora, although it’s all a little bit vague.

sudo chmod +s /bin/mount
sudo chmod +s /bin/umount
sudo chmod +s /usr/sbin/mount.cifs