2

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?

2
  • 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.
    – Caspar
    Aug 22, 2011 at 3:10
  • @Caspar - Yes it is however I would like to understand how it unifies directories and gives precedence to one over another Aug 22, 2011 at 3:17

2 Answers 2

6

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.

Linuxjournal has a fairly comprehensive writeup on how unionfs works, if you want something more than a simplified explanation of it

5
  • 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? Aug 22, 2011 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, 2011 at 3:21
  • @Journerman Geek - When you say a low precedence layer with the root filesystem do you mean any directory below \? Aug 22, 2011 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. Aug 22, 2011 at 3:29
  • Can I use unionfs as an overlay over an existing directory, where using that directory as mount point?. For example, I have dir1 with some files and dir2 with some another files, Can I use files of dir2 to appear under dir1 without just these 2 directories?
    – Anwar
    Jun 23, 2018 at 16:12
1

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.

2

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .