Course contentsShow
← Linux
Lesson 263 of 1,8193. The Filesystem Hierarchy and POSIX StandardsFree lesson

Volatile and Persistent Storage

Contrast the storage philosophies between /var, /tmp, and /run directories.

In this lesson, you will learn how the Linux filesystem categorizes data based on its expected lifespan and purpose through the /var, /tmp, and /run directories.

In Linux, not all data is created equal. Some files must survive a reboot (persistent), while others are only needed while the system is actively running (volatile). Understanding where to place these files is essential for system health.

/var: The Persistent Workhorse

The /var directory is for variable data that is expected to persist across reboots. This is the home for files that change frequently as the system operates, such as system logs (/var/log), printer spools, and databases. Because this information represents the state of your system, it is stored on the physical disk so it remains intact when you power down.

/tmp: The Temporary Workspace

The /tmp directory is for temporary files that applications create while they are working. While the files here might persist across a reboot depending on your specific distribution, the philosophy is that they are "disposable." Any user or process can create files here to exchange data or buffer information, but you should never assume a file you put in /tmp will be there tomorrow.

/run: The Volatile Memory

The /run directory is unique because it is usually a tmpfs (a filesystem stored in RAM). It holds data that describes the system since it was booted. Examples include PID files (which track running processes) or hardware state information. Because /run lives in your system's volatile memory, it is wiped clean the moment you shut down or restart.

To see the difference in how these are mounted, you can run the following command:

mount | grep -E '/var|/tmp|/run'

You will notice that while /var is typically attached to your permanent storage partition, /run is often identified as tmpfs, signaling that it is purely volatile memory.

Key Takeaway: Use /var for persistent logs and data, /tmp for short-term scratchpad files, and /run for transient runtime information that should vanish when the system powers down.