Background: On my system /tmp
is a regular part of the /
partition and I use it for a few important features of the system.
Current systemd
Approach: On new systems systemd
has started to take over mounting and in particular, mounting a tmpfs
over /tmp
at boot or even during updates. This is regulated in /usr/lib/systemd/system/tmp.mount
:
/usr/lib/systemd/system/tmp.mount
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Temporary Directory (/tmp)
Documentation=https://systemd.io/TEMPORARY_DIRECTORIES
Documentation=man:file-hierarchy(7)
Documentation=https://www.freedesktop.org/wiki/Software/systemd/APIFileSystems
ConditionPathIsSymbolicLink=!/tmp
DefaultDependencies=no
Conflicts=umount.target
Before=local-fs.target umount.target
After=swap.target
[Mount]
What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime,nosuid,nodev,size=50%,nr_inodes=400k
Problem: A few months ago during an update some running processes started writing error messages because important files in /tmp
disappeared - when systemd
is updated even in a running system tmpfs
is force-mounted over the existing /tmp
. It can also not be u(n)mounted ("filesystem busy"). This creates problems.
Partial Fix: I fixed it by commenting out the last 5 lines in the file given above. Also, I removed /usr/lib/systemd/system/local-fs.target.wants/tmp.mount
. However, each time systemd
is updated my customisation is lost - both files are no configuration files (though the wanted
file should be a flag). They will be replaced without warning.
Question: How can I permanently disable the mounting of a temporary (or any) filesystem over /tmp
? Perhaps there is a systemd
option I am missing? I am looking for a solution surviving a systemd
upgrade.
I did have a look at the manuals and linked documentation but nothing works. I also tried
chattr +i /usr/lib/systemd/system/tmp.mount
on my adjusted file but then systemd
will not be updated at all which isn't an option of course.
systemctl disable tmp.mount
removes the/usr/lib/systemd/system/local-fs.target.wants/tmp.mount
. Which symlink is created in/etc
?strace systemctl disable tmp.mount
didn't reveal anything to me./usr/lib/systemd/system/tmp.mount
file. I tried again now and will tell you after the next reboot.