4

On linux, temporary files are stored on a ramdisk:

tmpfs                  15G  4.0K   15G   1% /dev/shm

However, if there are several large files in /tmp/ I would assume that the files overflow onto disk? In such a case, if the machine has slower and faster disks, it would be preferable the faster disks to be used.

How does this work exactly and how can we configure on Linux where the overflow goes to?

mgorven
  • 30,615
  • 7
  • 79
  • 122
Martin
  • 41
  • 2

1 Answers1

4

tmpfs is the name of the RAM based filesystem, but it doesn't have to be mounted on /tmp or even used for traditional "temporary files". The example you've pasted is mounted on /dev/shm, which has nothing to do with /tmp, and so /tmp is probably just real disk.

Linux has no built in mechanism for /tmp "oveflow", so you'd have to set something up manually to achieve this. There is some distinction between /tmp and /var/tmp (IIRC /var/tmp tends to be used for bigger files), so mounting a tmpfs on /tmp and leaving /var/tmp on real disk may be good enough.

If you actually want it to overflow you'll have to setup a union filesystem like unionfs or aufs. These filesystems take multiple underlying directories and expose them as a single mountpoint. You can configure the priority of the underlying directories so that the tmpfs is used first, then the fastest disk, etc.

mgorven
  • 30,615
  • 7
  • 79
  • 122
  • Any copy-paste examples how to achieve these? i) mount tmpfs on /tmp ii) setup a union filesystem like unionfs or aufs so that the tmpfs is used first, then the fastest disk, etc. – Martin Aug 14 '12 at 08:40
  • You explicitly SHOULD NOT use `tmpfs` for `/var/tmp`. [Its files must survive reboots](https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s15.html). – Chai T. Rex May 05 '18 at 04:12