openSUSE:Tmp on tmpfs

(Redirected from Tmp-on-tmpfs)
Jump to: navigation, search

Introduction

tmpfs is a temporary filesystem that resides in memory. Mounting directories as tmpfs can be an effective way of speeding up accesses to their files and to ensure that their contents are automatically cleared upon reboot. This makes it a logical choice for some mountpoint such as `/tmp`

openSUSE Tumbleweed

It was decided to mount `/tmp` as tmpfs after a discussion on the opensuse-factory mailing list starting at:

https://lists.opensuse.org/opensuse-factory/2020-07/msg00130.html

Since Snapshot Version 20200806 fresh installations will will use tmpfs for /tmp by default. Existing systems will not be changed.

Converting old installations to use tmpfs

  • Backup any files you wish to keep from /tmp
  • Remove the line for /tmp from /etc/fstab
  • Remove all files in /tmp
  • Reboot

Old Installations already using /tmp on tmpfs before Snapshot 20200806

Before Snapshot 20200806, some users may have taken the steps to use the systemd-provided tmp.mount unit which had been relocated to /usr/share/systemd/tmp.mount. This most likely would have been in the form of one of the following two steps

  1. running "systemctl link /usr/share/systemd/tmp.mount"
  2. copying /usr/share/systemd/tmp.mount to /etc/systemd/system

For either scenario you first need to ensure you do not have any entry in /etc/fstab for for /tmp. If you do, remove it.

Then in the case of #1 you will NEED to remove /etc/systemd/system/tmp.mount to ensure you're using the new mount unit introduced as part of making /tmp on tmpfs default.

In the case of #2 it is not mandatory to remove /etc/systemd/system/tmp.mount but would be recommended to ensure you keep using the latest settings for /tmp on tmpfs in the event of any future updates changing our recommended settings.

openSUSE Leap

The following procedure was tested on openSUSE Leap 15.2

  • Backup files that you wish to keep from /tmp
  • Clear the /tmp folder by executing: rm -rf /tmp/*
  • Remove the line containing the mount point from /tmp in fstab
  • Execute the following command: systemctl link /usr/share/systemd/tmp.mount
  • Reboot

Using disk space for /tmp

If you do not wish to use tmpfs for tmp, you need to just define a mount point for it in /etc/fstab. Then tmpfs will no longer be used for /tmp.

This is easiest with btrfs and creating a subvolume, using the "mksubvolume /tmp" command.

Alternatively, you can mask the /tmp mount point with "systemctl mask tmp.mount". NOTE: If you only mask tmp.mount while using btrfs you will be filling up your root filesystem AND creating snapshots containing the contents of tmp (in other words, don't do this, and define a subvolume)

After the next reboot all files written to /tmp are stored again on the disk and will survive future reboots.

See also

Related articles

External links