knowledge/technology/linux/Systemd-Mounts.md
2023-12-04 11:02:23 +01:00

27 lines
No EOL
1.4 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
obj: concept
---
Mounts are _systemd_ unit files with a suffix of _.mount_. A unit configuration file whose name ends in ".mount" encodes information about a file system mount point controlled and supervised by systemd.
Mount Unit files like every unit file include the `[Unit]` and `[Install]` sections. Additionally all mount information is in the `[Mount]` section.
## Mount Section
Fields inside the mount section:
- `What` : Takes an absolute path of a device node, file or other resource to mount
- `Where` : Takes an absolute path of a file or directory for the mount point; in particular, the destination cannot be a symbolic link. If the mount point does not exist at the time of mounting, it is created as either a directory or a file. The former is the usual case; the latter is done only if this mount is a bind mount and the source (What=) is not a directory. This string must be reflected in the unit filename (example: `mountpoint=/home/me` -> `unit file: home-me.mount`).
- `Type` : Takes a string for the file system type. This setting is optional.
- `Options` : Mount options to use when mounting. This takes a comma-separated list of options. This setting is optional.
## Example
```
[Unit]
Documentation=man:fstab(5) man:systemd-fstab-generator(8)
SourcePath=/etc/fstab
[Mount]
What=/dev/sda1
Where=/mnt
Type=btrfs
Options=nosuid,nodev,nofail,compress=zstd,ro
```