8

A union mount presents a combined view of multiple directories (branches) in a single hierarchy. Ok, but how do I use one in practice, and which one?

Many union mount technologies are available on a modern Linux system: OverlayFS, aufs, UnionFS, various FUSE-based filesystems, …

Given a use case, how do I decide which one(s) are suitable? In particular:

  • Which ones require root access on a typical system? (In other words, can an unprivileged user create a union mount?)
  • Which ones can be mounted on / (with root access of course)?
  • Which ones support writing to the underlying branches? (I.e. if /foo and /bar are union-mounted to /union, can I write to /foo and /bar?)
  • Which ones support configurable policies for writes? (E.g. can I sent newly created files to branch B even though I'm getting content from branch A when a file exists on both branches?)
  • Which ones support a priority order between branches that depends on the files? (E.g. can I always get the newest file among all the branches that have it?)

Usage examples would be appreciated.

Please avoid answers that focus on a specific point. I'm looking for comprehensive answers that review the available software (something similar to What is a bind mount?). Good answers will be bountied.

10

On each of the specific points:

  • Root access: If it uses FUSE, it doesn't need root, if it doesn't use FUSE, it needs root unless you do special setup with either capabilities (potentially dangerous) or namespaces.

  • Mounting on /: I assume you mean as the root filesystem on startup, in which case any of them that run in kernel mode should in theory work, although some are more reliable than others. Most LiveCDs do this, so that's where I would suggest looking for information on this particular point.

  • Writing to the underlying branches: This depends on what you mean. If you mean propagating writes to the mounted view down to the lower branches, I have no idea. If you mean writing to the lower branches out-of-band from the main filesystem itself, technically all of the big three do, but they all require a remount to ensure that the change is propagated to the mounted view.

  • Configurable write policies: I don't know specifically about this, but I think the big 3 (UnionFS, AUFS, and OverlayFS) do not support it.

  • File-dependent priority order: I think this one kind of falls under the third sub-question as well, and like there, I don't know of any that specifically support it.

As to some more specifics on each of them:

  • UnionFS: As far as I can tell, this was the original stackable union filesystem implementation for Linux. It's been around for ages, and is used by a lot of Linux LiveCDs. It runs in kernel mode, and requires patches to the upstream kernel to be used.

  • AUFS: Originated as a fork of UnionFS, and then kind of became its own thing. This one attempted to get merged mainline and was rejected on the grounds of code quality. It's replaced UnionFS in some distros' LiveCDs, mostly Debian and Gentoo derivatives. Like UnionFS, it runs in kernel mode and requires patches to the upstream kernel.

  • OverlayFS: I don't know much about the original development of this one, other than it being supported on a couple of BSD derivatives too. It's notably the upstream overlay/union filesystem implementation in the Linux kernel. It also runs in kernel mode.

  • UnionFS-FUSE: This somewhat confusingly named project actually has nothing to do with UnionFS other than providing essentially the same functionality. It's the most widely used FUSE implementation of a union filesystem, but that's about all I know about it.

  • mhddfs: This one is an odd outlier that is more akin to a file granularity RAID-0 implementation than a conventional union filesystem. It supports balancing files across multiple backing directories based on space usage. It's also FUSE based.

A couple of specific things to note that aren't specific to a particular implementation:

  • All the in-kernel options have limitations on what the backing filesystems can be, most notably not working with networked filesystems or BTRFS.

  • All of the FUSE implementations have issues when used as a root filesystem. This isn't specific to union filesystem implementations, but is more an issue with FUSE in general.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.