mount
The mount.* family of state modules.
| Module | Summary |
|---|---|
mount.mounted | Ensure a filesystem is mounted at a mount point and recorded in fstab. |
All states also accept the full set of requisite parameters and Salt-parity state attributes — see Dependencies & Requisites.
mount.mounted
Ensure a filesystem is mounted at a mount point and recorded in fstab.
Source: pkg/state/modules/mount/mount_mounted.go
mount.mounted ensures SOMETHING is mounted at the mount point and, with persist (the default), that the declared fstab entry — device, fstype, opts, dump, and pass — is present. The mount point defaults to the state ID. device is required; fstype defaults to ext4 and opts to defaults.
Deliberately not compared: the LIVE mount's device/fstype/options. Comparing the declared fstab-language configuration against the kernel's /proc/mounts view needs Salt-style normalization (fstab-only options like nofail/_netdev never appear in /proc/mounts, negotiated fstypes like nfs→nfs4, UUID=/LABEL= device aliasing) — without it every mismatch would escalate to an unmount+remount of a live production filesystem on every run. That facet is deferred until the normalization exists; silent blindness beats production unmounts.
Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | No | State ID | mount point path; defaults to the state ID |
device | string | Yes | (none) | device or source to mount (a block device, UUID=/LABEL= alias, or NFS export); required |
fstype | string | No | ext4 | filesystem type (ext4, xfs, nfs, …); defaults to ext4 |
opts | string | No | defaults | mount options recorded in fstab (comma-separated); defaults to "defaults" |
dump | int | No | (none) | fstab dump field (fifth column); defaults to 0 |
pass | int | No | (none) | fstab fsck pass-order field (sixth column); defaults to 0 |
persist | bool | No | true | record the entry in fstab so it survives a reboot; defaults to true; a boolean that also accepts the integers 1 (true) and 0 (false) |
Effects
Check
Probes whether anything is mounted at the mount point (by reading /proc/mounts). With persist (the default) it also verifies the /etc/fstab entry EXACTLY matches the declared device, fstype, options, dump, and pass. Reports a change when the mount point is unmounted, or when the fstab entry is missing or differs. It deliberately does NOT compare the live mount's own device/fstype/options (see the deferred live-facet note), so a mount already serving the point never re-triggers a churn.
Apply
Re-probes the mount state (a self-contained flow: a watch-forced Apply bypasses Check). With persist, it writes or updates the fstab entry when it is missing or mismatched. It mounts the device ONLY when nothing is currently mounted at the point — an existing mount is never unmounted or remounted, even one that would look "wrong" under a naive live comparison. A fully converged entry (mounted, fstab matches) is a clean no-op. Reports the device, mount point, fstype, options, and persist flag in its details.
Revert
Undoes only what this run's Apply did: it unmounts a filesystem THIS Apply mounted and removes an fstab entry THIS Apply added — nothing else. A fresh instance (a standalone revert) recorded nothing and is an explicit clean no-op; it never unmounts a live filesystem or edits fstab for a mount it did not create.
Examples
Mount a data volume and record it in fstab
The mount point defaults to the state ID; device is required; persist (default true) writes the fstab entry.
/mnt/data:
mount.mounted:
- device: /dev/sdb1
- fstype: xfs
- opts: defaults,noatime
- pass: 2Mount an NFS export
fstab-only options like nofail/_netdev are recorded in fstab but never compared against the live mount.
nfs-share:
mount.mounted:
- name: /mnt/share
- device: 10.0.0.5:/vol
- fstype: nfs
- opts: defaults,nofail,_netdev
- require:
- "pkg.installed:nfs-common"Mount a device ad hoc
The bare positional argument is the mount point; device is a key=value.
zester 'db*' mount.mounted /mnt/data device=/dev/sdb1 fstype=xfs