Skip to main content

Merging folders with unionfs

Let's assume you have two folders with music, e.g. one with ripped albums and another with Jamendo downloads. On one hand you do want to seperate these two worlds and on the other you want to unite them to a single combined view. This is possible through unionfs. It's so awesome that I just have to write about it. :-) On a Debian-based system you install package unionfs-tools first. After that you're ready to check it out. Let's create two test folders one and two and merge them together:

$ mkdir one
$ touch one/1
$ mkdir two
$ touch two/2
$ mkdir merged
$ sudo mount -t unionfs -o “dirs=./one:./two” unionfs ./merged || dmesg | tail
$ ls merged/
1 2

On Ubuntu that already works, on Debian you might need to manually install the unionfs kernel module:

$ su
$ apt-get install unionfs-source
$ apt-get install module-assistant
$ module-assistant prepare
$ module-assistant build unionfs
$ module-assistant install unionfs
$ exit

That should be it. I'm quite happy some setup did not take hours for the first time...