$_ CLI In Depth
Learning progress 0%
lesson disks mounts archives

tmpfs & overlayfs

5 min read Module 12: Disks, Mounts & Archives Updated Dec 5, 2026
Cheat Sheet
0:00 / 3:18

tmpfs: files in memory

A tmpfs is a filesystem whose contents live in the kernel page cache and swap, not on a block device. Files you create there are fast to read and write, and they disappear at unmount or at shutdown. The directory /tmp is commonly a tmpfs for this reason: scratch files do not need to survive a reboot, and they should not leave debris on the disk.

A tmpfs has a size limit, which defaults to a fraction of physical memory. Writing past the limit fails with "No space left on device" even if the underlying system has free memory elsewhere. The size is a property of the mount, not of the files, and the kernel enforces it on every write.

BASH1 lines
awk '$2 == "/tmp" { print $1, $3 }' /proc/mounts

The source of a tmpfs is the word tmpfs, because there is no device behind it. In the lab, /tmp is a tmpfs, and that is why anything you put there vanishes when you reload the page. Use /workspace for files you want to keep for the rest of the session.

Choosing tmpfs has real trade-offs. Because the data lives in RAM and swap, heavy writes can push the system into memory pressure, and the kernel may move pages to swap, which is slower than RAM but often faster than a disk. A tmpfs is therefore well suited to scratch space, temporary build output, and lock files. It is a poor place for a database or a long download that you cannot afford to lose.

The same reasoning explains why a tmpfs has permissions and a size limit but no journal. There is no disk to protect and no crash to recover from, so the filesystem does not carry the structures that a disk filesystem needs to survive a power loss.

Overlay: stacking layers

An overlay filesystem merges several directory trees into one view. It has a set of lower layers, which are read-only, and one upper layer, which is writable. A lookup finds a file in the upper layer first and then the lower layers. A write to a file that exists only in a lower layer first copies the file up into the upper layer, and then the write happens there. The lower layer is never changed.

Deletion works through whiteouts. When you delete a file that exists in a lower layer, the overlay cannot remove it from that read-only layer, so it records a special marker in the upper layer that hides the lower file. The file still exists in the lower layer. It is merely invisible through the merged view.

This model is why container images are cheap. Many containers share the same read-only image layers, and each container adds its own small writable layer. The overlay merges them into a single root. The Linux kernel documentation describes the exact rules, and the lesson links to it below.

Finding the overlay in the lab

The root of this lab is an overlay. You can see the source, the type, and the options with one command. The options name the lower directories and the upper directory, which is the detail that shows the layering.

BASH1 lines
findmnt -n -o SOURCE,FSTYPE / | cut -c1-70

The type is overlay. The full options list is long, because it names several directories, but its first part reads like a list of lower and upper paths. You do not need to memorize those paths. What matters is the principle: reads come through the stack, writes land in the upper layer, and the lower layers stay fixed.

Note

A lower layer on this machine is a read-only disk image, so the files that came with the system cannot be edited in place. Writes to them land in a writable layer above, and that layer lives in memory. A reload of the lab page returns the root to its starting state.

Writing in a layered tree

Files that come with the system live in the lower layer, and your user cannot change them. Writes to new paths always land in the writable layer. A file you create in /workspace therefore lives in the upper layer from the first byte, and the demonstration below uses such a file. The copy-up rule still applies to any lower file that a process with the right permissions edits, because the overlay copies the file up before the first write.

BASH2 lines
echo hello > notes.txt
findmnt -n -o FSTYPE -T notes.txt

The second command reports overlay, because the file lives in the merged root. Reading the same information from the mount table gives the same answer, and that is the point: the path tells you nothing about the layer, but the mount does.

Why this matters when you debug

Knowing the layering changes how you investigate a problem. If a file is "missing" after an update, the upper layer may hide a lower file through a whiteout. If a change disappears after a reboot, you were probably writing to a tmpfs or to the upper layer of a stateless system. If a write fails on a read-only disk, look at the lower layer, not at the permissions of the file.

Hands-on: classify the mounts

Build a short report that lists each mount point with its type for the two kinds of filesystem in this lesson. The report separates the durable overlay root from the memory-backed tmpfs, so you can see which paths will survive a reload.

BASH1 lines
awk '$3 == "tmpfs" || $3 == "overlay" { print $2, $3 }' /proc/mounts

The output lists / with overlay and /tmp with tmpfs, and it may list more tmpfs mounts. Read each line and ask whether the data behind it would survive a reload. That question is the practical test for any mount you meet.

The overlay root: layers, copy-up and whiteouts

Visualizer

The root filesystem here is two layers merged into one view. Reads fall through to the read-only layer, writes go to a RAM layer, and deletes leave a marker.

1 / 4
Root filesystem /
uppertmpfs: read-write, in RAM
lowererofs on /dev/wda: read-only

The root / is an overlay of two layers. The upper layer is a tmpfs in RAM and takes all writes. The lower layer is a read-only image. You see the merged result.

findmnt /
Terminal lab · 2 steps · real Linux in your browser

Classify the root and /tmp

Find which mount is the overlay root and which is the memory-backed tmpfs.

01
Record the type of /tmp
Use findmnt to print the type of the filesystem that holds /tmp, and save it in tmp-type.txt. ``bash findmnt -n -o FSTYPE /tmp > tmp-type.txt ``
Show hint for step 1
findmnt -n -o FSTYPE /tmp prints only the type. Redirect it into tmp-type.txt.
02
Record the type of the root
Do the same for the root directory. The answer is the layered filesystem described in this lesson. Save it in root-type.txt. ``bash findmnt -n -o FSTYPE / > root-type.txt ``
Show hint for step 2
Ask about / rather than /tmp. The lesson names the type of the merged root.
Check yourself Question 1 of 4
Concept Check Where tmpfs data lives recall

What happens to the files on a tmpfs when it is unmounted?

Recap & Key Takeaways

A tmpfs keeps files in memory, has a size limit set by the mount, and loses its contents at unmount or shutdown.
An overlay merges read-only lower layers with one writable upper layer, copies a file up before a write, and uses whiteouts to hide deleted lower files.
In the lab, the root is an overlay and /tmp is a tmpfs, so files in /workspace persist for the session and files in /tmp do not survive a reload.
Use findmnt -T or the mount table to decide whether a path is durable before you trust it with important data.
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue