What Is a Union Filesystem? How Multiple Directories Become One Tree
A union filesystem is a way to present multiple directory trees, often called branches or layers, through one combined path. Reads follow rules that decide which source wins when paths overlap. Writes may go to a designated writable layer or use copy-on-write to preserve the source. The term “union” alone does not define precedence, write destinations, or deletion behavior; those vary by implementation.
What Is a Union Filesystem? How Multiple Directories Become One Tree
A union filesystem is a way to present multiple directory trees, often called branches or layers, through one combined path. Reads follow rules that decide which source wins when paths overlap. Writes may go to a designated writable layer or use copy-on-write to preserve the source. The term “union” alone does not define precedence, write destinations, or deletion behavior; those vary by implementation.
Read-only container image layers combined with a per-container change layer are a familiar use of this idea. Image formats and runtime layer management are separate from the filesystem mechanism itself. This article explains the general concept and uses Linux OverlayFS and AUFS as implementation examples, not interchangeable specifications.
Why combine multiple trees into one path?
Operating systems normally mount filesystems at separate paths. An application that needs files from both locations must know how to combine those paths. A union filesystem exposes several trees as one logical tree, making it possible to share a common base while keeping changes in separate layers.
The diagram is conceptual. Which copy wins when base and patch contain the same name depends on the implementation’s branch order and policy.
base tree ───┐
├─ union mount ─→ one tree visible to the application
patch tree ──┘ conflict rules vary by implementation
│
└─ write destination also variesThis can avoid distributing duplicate common files while separating changes. For example, several test environments could read the same base files and store their own modifications separately. This is an illustrative design, not a procedure for a particular container runtime.
Which file appears when names overlap?
The same path can exist in multiple branches, so the filesystem needs a conflict rule. A common design shows the file from the higher-priority branch and hides lower copies. The direction of priority and the way directories merge can differ.
Combining directory entries does not combine every attribute. A merged listing may include names from multiple layers, while permissions, ownership, timestamps, and extended attributes come from a particular layer according to the implementation. If backup or file-monitoring software assumes inode numbers are stable identifiers, verify that assumption with the specific implementation and configuration.
How can writes and deletions preserve the source?
With a copy-on-write design, the first modification of a file in a read-only base can copy it to a writable layer and apply the change there. Linux kernel documentation describes this behavior for OverlayFS: a lower object is copied up when an operation requires write access. The first write to a large file can therefore require substantial copying, which matters for storage and performance planning.
A shared base file can also be hidden without physically deleting it. OverlayFS uses a whiteout in the upper layer to hide the matching lower name from the merged view. AUFS documents its own whiteout rules for hiding lower entries. The on-disk representation and directory-wide hiding mechanisms vary, so do not transfer one implementation’s internal format to another.
Not every union filesystem uses copy-on-write. AUFS, for example, documents policies for choosing among multiple writable branches for new files and copy-up. Operators should check branch permissions, collision precedence, write targets, and deletion representation for the implementation they actually use.
How do OverlayFS and AUFS differ?
Both combine layers into one view, but their options and internal rules are not identical. Linux OverlayFS is commonly described in terms of lower layers plus a writable upper and work directory. AUFS documentation describes ordered branches, per-branch permissions, and policies for selecting writable branches and copy-up targets. Do not generalize one implementation’s whiteout, rename, or inode behavior into a guarantee for another.
| What to check | Question | Why it matters |
|---|---|---|
| Path conflicts | Which copy wins when names overlap? | The application may see different content. |
| Write path | Where do new files and modifications go? | Storage, performance, and source preservation differ. |
| Deletion | Is a lower object removed or hidden with a marker? | A deletion in the merged view may not delete the source. |
| Metadata and identity | How are permissions, xattrs, st_dev, and st_ino exposed? | Backups, monitoring, and security decisions may be affected. |
| Constraints | Are rename, hard-link, or filesystem combinations limited? | Application file operations can fail. |
A container-layer mental model
Imagine combining a read-only application base with a separate writable layer. A read of a configuration file returns whichever version the merge rules select. On modification, the implementation may copy the file into the writable branch; on deletion, it may record a hiding marker instead of removing the base copy. If the writable layer is discarded when a container is recreated, its changes may disappear. Check the runtime’s actual storage and volume model for data that must persist. This scenario is illustrative, not a tested runtime result.
When diagnosing a problem, first identify the actual mount type and options, branch order, and writable layer. Then check whether the same path exists in multiple layers and whether a whiteout is involved. If stat results or renames differ from application expectations, reproduce the case against the official documentation for the specific implementation, kernel, and runtime versions. Avoid editing backing layers directly unless the implementation provides a supported management path, since doing so can break the combined view’s consistency.
Summary
A union filesystem is a general way to expose several trees through one path; OverlayFS and AUFS are implementations with different rules. The visible file, write destination, deletion marker, metadata, and identity behavior all depend on the implementation and its configuration. When designing or troubleshooting container storage, verify those rules instead of assuming that every layered filesystem behaves the same way.
Sources
[Linux kernel documentation: Overlay Filesystem](https://docs.kernel.org/filesystems/overlayfs.html)
[AUFS documentation](https://aufs.sourceforge.net/aufs.html)
[Docker Docs: Storage drivers](https://docs.docker.com/engine/storage/drivers/)
The Linux kernel OverlayFS and AUFS project documentation were checked on November 23, 2026. Specific behavior depends on the selected implementation and version.