systemd-mount
Mount a file system or storage object
TLDR
Mount a file system (image or block device) at /run/media/system/LABEL where LABEL is the filesystem label or the device name if there is no label
Mount a file system (image or block device) at a specific location
List all local, known block devices with file systems that may be mounted
Create an automount point that mounts the actual file system at the time of first access
Unmount one or more devices
Mount a file system (image or block device) with a specific file system type
Mount a file system (image or block device) with additional mount options
SYNOPSIS
systemd-mount [OPTIONS...] WHAT [WHERE]
systemd-mount [OPTIONS...] --list
PARAMETERS
WHAT
Specifies the source of the mount operation. This can be a device path (e.g., /dev/sdb1), a UUID (e.g., UUID=...), a label (e.g., LABEL=...), a network share (e.g., //server/share), or a source path for a bind mount.
WHERE
Specifies the absolute path to the mount point directory. This directory will be created if it doesn't exist and --mkdir is used.
-h, --help
Shows a short help message and exits.
--version
Shows a short version string and exits.
--list
Lists existing mount and automount units, including those derived from /etc/fstab, and exits.
--automount
Creates an automount unit instead of a mount unit. The filesystem will be mounted only when it is first accessed.
--fsck=[yes|no|auto]
Controls whether to run a filesystem check (fsck) before mounting. Defaults to 'auto'.
--options=STRING
A comma-separated string of mount options to pass to the mount command (e.g., 'ro,nosuid').
--property=ASSIGNMENT
Sets a systemd unit property for the generated mount unit (e.g., 'TimeoutSec=30'). Can be specified multiple times.
--description=TEXT
Sets the description for the generated mount unit.
--mkdir[=MODE]
Creates the mount point directory if it does not exist. An optional mode (octal) can be specified; defaults to 0755.
--timeout=SECS
Sets a timeout for the mount operation. If the mount does not complete within this time, the operation fails.
--no-block
Does not wait for the mount operation to finish. The command returns immediately.
--force
Forces the creation and start of the unit, even if the mount point or device is already in use. Can unmount existing mounts if needed.
--discover
Discovers existing mount points defined in /etc/fstab and attempts to create and activate corresponding units. Use with --list or without WHAT/WHERE.
DESCRIPTION
systemd-mount is a utility for creating and managing transient systemd mount and automount units from the command line. It provides a convenient way to temporarily mount file systems without needing to manually write .mount unit files. This command integrates seamlessly with the systemd ecosystem, allowing for advanced control over mount options, dependencies, and lifecycle management. It can handle various sources like device nodes, UUIDs, labels, and network shares, and mount them to specified directories. While primarily designed for transient operations, systemd-mount can also discover and manage existing mount points defined in /etc/fstab, making it a versatile tool for both temporary and persistent filesystem management within a systemd environment.
CAVEATS
systemd-mount typically requires root privileges to perform mount operations, as it directly interacts with kernel-level mounting facilities.
By default, units created by systemd-mount are transient. This means they are only active during the current boot session and will be automatically removed after unmounting or a system reboot. They do not persist across reboots unless explicitly managed otherwise (e.g., via /etc/fstab entries that can be discovered with --discover).
This command does not modify your /etc/fstab file. For permanent mounts, /etc/fstab is still the primary method, and systemd-mount --discover can then be used to activate them dynamically.
TRANSIENT UNITS
Units created by systemd-mount are, by default, 'transient'. This means they are generated in runtime and are automatically cleaned up when they are no longer needed (e.g., after unmounting) or upon system shutdown/reboot. This behavior is ideal for temporary mounting needs, such as attaching external drives or temporary network shares. For persistent mounts, defining them in /etc/fstab is the standard approach, which systemd-mount can then interact with via the --discover option.
INTEGRATION WITH SYSTEMD-RUN
While systemd-mount creates and starts mount units, its operations can be further integrated with systemd-run. For instance, one could use systemd-run to execute a command within a specific mount environment or to manage the lifetime of the mount unit as part of a larger service. This integration highlights systemd's modular design, allowing different components to work together for complex system management tasks.
HISTORY
systemd-mount emerged as part of the broader systemd project, which began development around 2010 and rapidly became the de-facto init system for most major Linux distributions. Its development was driven by the need for a more unified and programmatic approach to managing system resources, including filesystem mounts. Prior to systemd-mount, temporary mounts often involved manual mount(8) commands, which lacked integration with the service manager's lifecycle. systemd-mount addressed this by providing a way to create temporary, service-managed mount units, aligning mount operations with systemd's philosophy of declarative unit management and automatic dependency resolution.
SEE ALSO
systemd(1), systemd.mount(5), systemd.automount(5), systemd-run(1), mount(8), umount(8), fstab(5)