Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
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 '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 –  PeanutsMonkey Aug 22 '11 at 3:17

2 Answers 2

up vote 3 down vote accepted

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

share|improve this answer
    
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? –  PeanutsMonkey Aug 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 \? –  PeanutsMonkey Aug 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. –  PeanutsMonkey Aug 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.

share|improve this answer
    
    
Thanks. I did finally figure it out but will have a read of what it is because I have no idea of its function. –  PeanutsMonkey Aug 22 '11 at 3:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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