0

Due to a deficit of RAM on Debian, I need to move /tmp to SSD drive. But I still can't figure it out, how to do that so the programs that use it will still access it under /tmp path.

So basically, what I want to achieve is move /tmp from ramdisk to for example /home/tmp. And be able to access it through /tmp

2
  • make link to your destination from /tmp
    – asktyagi
    Commented May 28, 2019 at 13:46
  • Please note consumer SSDs will shut down or go Read-Only when you reach their specified number of writes, as described in tomshardware.com/reviews/… so I'd watch your number of writes and budget for a replacement SSD accordingly.
    – K7AAY
    Commented May 28, 2019 at 20:12

1 Answer 1

1
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:

  1. 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
  2. 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.
  3. 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
# ...

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .