UnionFS

From Wikipedia, the free encyclopedia

UnionFS is a Linux filesystem service which implements a union mount for Linux file systems. It allows files and directories of separate file systems, known as branches, to be transparently overlaid, forming a single coherent file system. Contents of directories which have the same path within the merged branches will be seen together in a single merged directory, within the new, virtual filesystem.

UnionFS is mainly used in Live-CD or diskless systems, where the read-only root directory is combined with a tmpfs filesystem (which resides in memory and is writable). This way, all the files from read-only root can be modified, and the modification is kept in memory.

The different branches may be read-only or read-write file systems, so that writes to the virtual, merged copy can be directed to a specific real filesystem. This leads to one other useful purpose for union mounts, which is to make a filesystem appear as writeable, but without actually allowing writes to change the filesystem, also known as copy-on-write. This may be desirable when the media is physically read-only, such as in the case of CD-ROMs, or for using a single common template for a number of filesystems, or perhaps for security reasons. The Linux implementation, UnionFS, is sometimes used as an ad-hoc snapshotting system.

When mounting branches, the priority of one branch over the other is specified. So when both branches contain a file with the same name, one gets priority over the other.

On LiveCDs it is used as a way of overlaying a writeable file system on top of read-only media. In KNOPPIX for example the union of the file system on the CD-ROM or DVD may be made with the file system contained in an image file called knoppix.img on a USB memory stick which has priority over the read-only filesystem. The user sees then a logical file system where it is possible to add and change files anywhere. What happens on the physical level is that if a file which resides in the read-only branch is replaced by a new version it is put into the image file. As the union file system merges the two branches transparently the user just sees the new version.

More detailed description of using unionfs in a Live CD environment can be found at www.linux-live.org.

[edit] Other implementations

Unionfs for Linux has two versions. Version 1.x is a standalone one that can be built as a module. Version 2.x is a newer, redesigned, and reimplemented one. As of January 2007, Unionfs 2.0 has been included into Andrew Morton's Linux -mm tree, thus slated for eventual inclusion in the Linux kernel mainline source tree. Version 2.x is the smallest implementation of unioning for Linux, it is heavily tested and inspected by many kernel developers, and it is more efficient.

aufs is an alternative version of unionfs for Linux.

Plan 9 from Bell Labs operating system uses union mounts extensively to build custom namespaces per user/processes. The same concept, implemented as "union mount" has also been available in BSD, since at least 1995[1].

Several previous attempts have been made to add this feature to Linux, but none was maintained for long. For quite a while Linux has had the bind mount feature, which allows attaching a directory in more than one location in the filesystem, and this feature is present in other operating systems including MS-DOS, but this is a completely different concept to union mounts.

[edit] References

  1. ^ USENIX 1995 Technical Conference Proceedings

[edit] External links

In other languages