sudo apt install cifs-utils
sudo mkdir /mnt/linux
Add the following content to /root/.smbcredentials
:
username=samba_username
password=samba_password
sudo mount -t cifs -o rw,credentials=/root/.smbcredentials,dir_mode=0775,file_mode=0775,uid=1000,gid=1000 //fileserver.example.co.uk/linux /mnt/linux
Config | Description |
---|---|
x-systemd.automount |
Automatically remounts the CIFS share in case the NAS went offline for some time. |
noatime |
Access timestamps are not updated when a file/folder is read. |
Add the following line to /etc/fstab
:
//fileserver.example.co.uk/linux /mnt/linux-share cifs rw,x-systemd.automount,noatime,credentials=/root/.smbcredentials,dir_mode=0775,file_mode=0775,uid=1000,gid=1000 0 0
systemd
will create mount units in /run/systemd/generator/
from /etc/fstab
on boot.
Reload mount unit
sudo systemctl daemon-reload
sudo mount -a
Check service status & service file location
systemctl status <service-name>
Modify /lib/systemd/system/<service-name>.service
, add:
[Unit]
RequiresMountsFor=/mnt/path
Reload systemd daemon
systemctl daemon-reload