Automatically Mount Samba Share

[!tip]
If you encounter issues, or need to query what certain comma separated parameters mean then query the manual: man mount.cifs.

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

About

I'm a technology professional who's been passionate about computers since my Grandad introduced me to an Intel 386 back in the 90s when I was a kid. Those moments inspired a passion within for technology, and I've been playing around with anything with a circuit board ever since. Whenever I have a moment you can probably find me working on something computer-related, and this is where I like to write about those moments.