How to Move /tmp into Memory


Just got my OpenSUSE 15.2 install finished and now working on setup but I’m discovering many things have changed since 15.1.

What has been making me scratch my head for a while is how to move the /tmp folder into ram?

On LEAP 15.1, there is a line in the fstab to do this:

tmpfs /tmp tmpfs size=2048m 0 0
On 15.2, this prevented the system from booting. On another page, I found a different method which also did not work and prevented
the system from booting:

ln -s /usr/share/systemd/tmp.mount /etc/systemd/system/
What is the way to move /tmp into ram and give it a size limit on OpenSUSE LEAP 15.2?**


  • Itai

As far as I know, that should still work.

On another page, I found a different method which also did not work and prevented
the system from booting:

ln -s /usr/share/systemd/tmp.mount /etc/systemd/system/

I am using that here (on Leap 15.2), and it is working.

Are there any error message that indicates what is going wrong?

Are you using “btrfs”? Is there already an “/etc/fstab” entry to mount a subvolume on “/tmp”? If there is, you might want to comment out that line.


It worked. Thank you for confirming that it should :slight_smile:

The error was that I had removed the /tmp instead of its content so the mount-point did not exist since I wanted to avoid blocks used by unreachable files,
which I don’t know what would have happened.

Retried with an empty /tmp and the fstab line above worked. I have no idea what that other procedure is supposed to do.

Thanks again,

  • Itai

I have on 15.1

tmpfs            /tmp       tmpfs size=25%,uid=root,gid=root,mode=1777 0 0

Never tested it on 15.2 though.

Same thing works with 15.1 and 15.2, the only thing is that you need the mount point to be there.

Defaults on my system (no entry in /etc/fstab):

erlangen:~ # grep /tmp /proc/mounts 
tmpfs /tmp tmpfs rw,nosuid,nodev,size=16280292k,nr_inodes=409600 0 0
erlangen:~ # 

systemd takes care:

erlangen:~ # systemctl cat 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.

Description=Temporary Directory (/tmp)

erlangen:~ # 

Change settings by running “systemctl edit --full tmp.mount”.