SMB mount unit

Sample MOUNT unit for SMB share


It is also possible to store the username and password in a safe location readable only by root.

Replace the $VARIABLES with the values for your system

The package smbclient is enough.

/etc/systemd/system/data-smb-video.mount

[Unit]
Description=NAS SMB video share
After=network.target

[Mount]
What=//server/video
Where=/data/smb/video
Type=cifs
Options=_netdev,iocharset=utf8,rw,file_mode=0777,dir_mode=0777,user=$SMBUSER,password=$SMBPASS,workgroup=$WORKGROUP
TimeoutSec=30

[Install]
WantedBy=multi-user.target

NOTE: According to the archlinux wiki the uid and gid can cause I/O errors.

Warning: Using uid and/or gid as mount options may cause I/O errors, it is recommended to set/check correct File permissions and attributes instead. - https://wiki.archlinux.org/index.php/Samba#Manual_mounting

More information on Samba can be found on the archlinux wiki