The systemd way of overriding
tmp.mount, or extending it, is to add a local override in
/etc/systemd/system. You can either copy the existing
/usr/share/systemd probably) and edit the copy, or better yet, add configuration snippets to only change the mount options, by running
sudo systemctl edit tmp.mount
in the editor which opens. This will
- create a directory called
- inside that directory, add a file called
override.conf containing the text above.
systemd.mount still says that
In general, configuring mount points through
/etc/fstab is the preferred approach.
so you may just want to do that, i.e. edit
/etc/fstab to add the
size=... option on the
/tmp line (adding it if necessary):
tmpfs /tmp tmpfs mode=1777,strictatime,nosuid,nodev,size=1G 0 0
In fact, this is the recommended approach to change mount options for any of systemd’s “API file systems”:
Even though normally none of these API file systems are listed in
/etc/fstab they may be added there. If so, any options specified therein will be applied to that specific API file system. Hence: to alter the mount options or other parameters of these file systems, simply add them to
/etc/fstab with the appropriate settings and you are done. Using this technique it is possible to change the source, type of a file system in addition to simply changing mount options. That is useful to turn
/tmp to a true file system backed by a physical disk.
API file systems include the following:
/sys/firmware/efi/efivars. systemd ensures they are mounted even if they are not specified in
/etc/fstab or a mount unit.
Be careful when sizing
tmpfs file systems: they will end up competing with whatever else in your system needs memory (including swap), and can result in memory exhaustion when you don’t expect it; at worst this can result in deadlocks.