I have come across various articles as well as an explanation on Wikipedia however am having a hard time understanding what it means. So far I understand that UnionFS is a module that provides a union view of directories. It resides a a layer above the directories which are mounted. UnionFS does not have a mount point.

What confuses me is how does UnionFS know what should be shown in a unified manner?

Isn't that covered by the wikipedia article? 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.
–
CasparAug 22 '11 at 3:10

@Caspar - Yes it is however I would like to understand how it unifies directories and gives precedence to one over another
–
PeanutsMonkeyAug 22 '11 at 3:17

2 Answers
2

UnionFS works at a directory level, as opposed to a device level, so it dosen't have a mount point - it sits over existing mount points each of which might be a branch - for example, having a base layer (or to use proper terminology - a low precedence layer with the root filesystem) on a read only iso9660 cd rom file system, and a branch on a ramdisk. Each branch is assigned a precedence and a branch with a higher precedence overrides one of a lower precedence.

If a directory exists in two underlying branches, the contents and attributes of the Unionfs directory are the combination of the two lower directories.

If a file exists in two branches, the contents and attributes of the Unionfs file are the same as the file in the higher-priority branch, and the file in the lower-priority branch is ignored.

Finally if there's a duplicate, the duplicate directory is hidden to simplify things.

Thanks. I did read the article on LinuxJournal but what confused me was how does this work with say a Linux LiveCD and a base installation of say Windows. Also what do you mean by a base layer and a branch on ramdisk?
–
PeanutsMonkeyAug 22 '11 at 3:19

clarified base layer. A ramdisk is simply a disk image or a special filesystem entirely run on ram.
–
Journeyman Geek♦Aug 22 '11 at 3:21

@Journerman Geek - When you say a low precedence layer with the root filesystem do you mean any directory below \?
–
PeanutsMonkeyAug 22 '11 at 3:27

@Journerman Geek - I came across this article at LWN http://lwn.net/Articles/217084/ and from what I understand a UnionFS is managed manually not automatically i.e. an administrator would have to create it as opposed to it being dynamically created.
–
PeanutsMonkeyAug 22 '11 at 3:29

Its VFS operations are small stubs that call back into the VFS layer of the underlying filesystems. So when you e.g. read a directory, it reads the directories of the underlying filesystems and merges the file lists.