Glossary

tmpfs

tmpfs is a filesystem type that stores its contents in RAM (and swap, if configured), rather than on a block device. Files written to a tmpfs mount are extremely fast to access but volatile: unmounting the filesystem or rebooting the machine destroys everything in it. Modern Linux uses tmpfs for many runtime directories, including /run, /dev/shm, /tmp on most distributions, and /run/user/$UID for per-user runtime data.

To create a tmpfs mount manually:

sudo mount -t tmpfs -o size=512M tmpfs /mnt/ram
mount | grep tmpfs

Unlike a classical ramdisk, tmpfs grows on demand up to its configured size and releases memory when files are deleted. If the system is under memory pressure, pages of a tmpfs file can be swapped out like any other anonymous memory, so a large tmpfs does not hard-pin RAM.

tmpfs is ideal for anything that is both temporary and sensitive to disk latency: scratch files in build systems, shared-memory sockets, and the ubiquitous /dev/shm used by POSIX shared memory. It is also the reason why df -h on a modern Linux box shows a handful of small tmpfs filesystems alongside the real ones.

Related terms: /tmp, /run

Discussed in:

Also defined in: Textbook of Linux