Use systemd to mount CIFS drive

From AcrodusWiki
Revision as of 15:24, 23 November 2024 by Alex (talk | contribs)

This two examples of unit files that enable a systemd service to mount a cifs drive.

[Unit]
Description=cifs mount script
Requires=network-online.target
After=network-online.service
[Mount]
What=//10.68.64.19/Reports/NMS
Where=/mnt/nas
Options=domain=ewr,username=nms,password=Atkins123!
Type=cifs
[Install]
WantedBy=multi-user.target
[Unit]
Description=Automount NAS
[Automount]
Where=/mnt/nas
[Install]
23WantedBy=multi-user.target

Note for Alex.

Make sure the name of the .mount and .automount files are the path of the mount point otherwise it will fail.

Also, use man systemd.mount for more information.