3

Many people recommend setting up a Ramdisk for the /tmp directory. What Use do I get from it? Is there any difference when using an all SSD / all HDD Sytem?

1 Answer 1

1

As the File System Hierarchy Standard states

Programs must not assume that any files or directories in /tmp are preserved between invocations of the program.

http://refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html#TMPTEMPORARYFILES

So this data need not be kept and probably should be cleared out often. However most modern Linux distributions now map /tmp -> /run/tmp/ instead of some complicated per application exit purging and /run MUST be cleared every boot so this is just easier.

This directory contains system information data describing the system since it was booted.

http://refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html#VARRUNRUNTIMEVARIABLEDATA

Most distributions therefor implement /run (and therefor /tmp -> /run/tmp) as a tmpfs. This ensures any applications that don't cleanup their files in /tmp get purged every boot.

5
  • 3
    What distributions implement /tmp as /run/tmp? I just checked an Arch and an Ubuntu 16.04.03 system and neither of them seems to (but maybe I don't know how to check, how would I check?). How exactly would that work? As a symlink? A mount --bind?
    – terdon
    Nov 10, 2017 at 12:06
  • How do this answer relates to ubuntu?
    – pim
    Nov 10, 2017 at 12:34
  • FWIW - you can check if a system is mounted tmpfs with findmt , example, Ubuntu 17.10, findmnt --target /run yields /run tmpfs tmpfs I do not know when the change was made, probably with systemd. /tmp is not tmpfs , but, because it is a sub directory of /run , /run/tmp is tmpfs . findmnt --target /tmp yields / /dev/sda1 ext4 Same results with systemd-private* , noting in /tmp if tempfs nor is /tmp linked to /run/tmp drwxrwxrwt 14 root root 4096 Nov 10 09:09 tmp , /tmp is a directory
    – Panther
    Nov 10, 2017 at 16:10
  • Not sure about other distros ;) . In addition , not all distros , apps , or services honor the FHS standards. data in /tmp should be cleared at reboot and /var/tmp should be preserved and /run/tmp is tmpfs so by definition will be cleared at boot regardless of what apps want. Not all apps honor these standards (search launchpad for bugs with /tmp and you will find specifics).
    – Panther
    Nov 10, 2017 at 16:10
  • 1
    I think that the original question is about the usage of ram. What you write is correct, but why I should waste the ram for such files? Dec 20, 2018 at 8:59

You must log in to answer this question.

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