From bb78070a32d7d44dc916971422cfb76b03cf0229 Mon Sep 17 00:00:00 2001 From: RealStickman Date: Sun, 11 Sep 2022 14:22:54 +0200 Subject: [PATCH] Add systemd automount docu --- .../30.systemd-automount/default.en.md | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 pages/02.linux/30.systemd-automount/default.en.md diff --git a/pages/02.linux/30.systemd-automount/default.en.md b/pages/02.linux/30.systemd-automount/default.en.md new file mode 100644 index 0000000..6556744 --- /dev/null +++ b/pages/02.linux/30.systemd-automount/default.en.md @@ -0,0 +1,46 @@ +--- +title: Systemd Automount +--- + +[toc] + +Systemd can be used to mount filesystems not only on boot (simple `.mount` file), but also on request by any process. (`.automount` file) + +## Mount file +The `.mount` file should be placed in `/etc/systemd/system` +**NOTE: The filename must be (mountpoint).mount with slashes `/` being replaced with dashes `-`** +Example: `/mnt/target` --> `mnt-target.mount` + +Here's an example `.mount` file for a CIFS share +``` +[Unit] +Description=cifs mount + +[Mount] +What=//(url/ip)/(sharename) +Where=/(target mountpoint) +Type=cifs +Options=defaults,username=(user),password=(password),file_mode=0640,dir_mode=0750,iocharset=utf8,uid=(local uid),gid=(local gid) + +[Install] +WantedBy=multi-user.target +``` + +## Automount file +The corresponding `.automount` file needs to have the same name as its `.mount` file +Example: `mnt-target.mount` and `mnt-target.automount` + +``` +[Unit] +Description=cifs automount + +[Automount] +Where=/(target mountpoint) + +[Install] +WantedBy=multi-user.target +``` + +Enable the `.automount` file to mount the filesystem when necessary +`# systemctl enable (target-mount).automount` +