systemctl mask tmp.mount
This command tells systemd
not to mount the RAM-based filesystem (tmpfs
) on /tmp. To apply the change, you must then reboot the system.
In most cases this is all you need to do. It is not necessary to redirect /tmp to /home/tmp, or anywhere else. This method is recommended in official systemd documentation --
I just want to get rid of the tmpfs backed /tmp!
You have three options:
- Disable any mounting on /tmp so that it resides on the same physical file system as the root directory. For that, execute
systemctl mask tmp.mount
- Mount a different, physical file system to /tmp. For that, simply create an entry for it in /etc/fstab as you would do for any other
file system.
- Keep /tmp but increase/decrease the size of it. For that, also just create an entry for it in /etc/fstab as you would do for any other
tmpfs file system, and use the right size= option.
Why is it not necessary to redirect /tmp e.g. to /home/tmp?
The above should leave /tmp as a writeable directory inside /
(the root filesystem). Software for Debian or most other Linux distributions should only use /tmp for a small set of files, so I would not worry about running out of space in the root filesystem. This requirement mostly appears to derive from the idea that /tmp may be a RAM filesystem :-).
You do not need to worry that /tmp will fill up with stale files over time. /tmp is automatically cleaned up at boot time:
$ cat /usr/lib/tmpfiles.d/tmp.conf
# 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.
# See tmpfiles.d(5) for details
# Clear tmp directories separately, to make them easier to override
D /tmp 1777 root root -
#q /var/tmp 1777 root root 30d
# There are more lines here, but they are not important to this answer
# ...