Skip to content

Latest commit

 

History

History
58 lines (41 loc) · 1.56 KB

mount-smb-share.md

File metadata and controls

58 lines (41 loc) · 1.56 KB

Mount SMB Share in Debian

sudo apt install cifs-utils
sudo mkdir /mnt/linux

Add the following content to /root/.smbcredentials:

username=samba_username
password=samba_password

Try to Mount with a One-Time Command

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.

Make the Mount Permanent

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

Mount All Filesystems Mentioned in fstab

sudo mount -a

Make a service wait for mount

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

Refer