Skip to content
Related Articles

Related Articles

How to Transparently Overlaid Two Directories Using UnionFS in Linux?
  • Difficulty Level : Easy
  • Last Updated : 11 Oct, 2019

To transparently overlay two directories one on top of the other using UnionFS following steps must be followed:

Step 1: Enter into the superuser mode and install the unionfs-fuse package.

$ apt install unionfs-fuse

Step 2: Now create a dir1 directory and then create two files f1 and f2 inside that directory.



$ mkdir /root/dir1
$ touch /root/dir1/f1
$ touch /root/dir1/f2

Step 3: Create a dir2 directory and then create two files f3 and f4 inside that directory.

$ mkdir /root/dir2
$ touch /root/dir2/f3
$ touch /root/dir2/f4

Step 4: Create a directory called union

$ mkdir /root/union

Step 5: Now mount dir1 and dir2 to the union directory using unionfs-fuse and then list the files.

$ unionfs /root/dir1:/root/dir2  /root/union/
$ ls /root/union/
f1 f2 f3 f4

Hence we can see that all the four files f1, f2, f3, f4 are available in the directory union.

Step 6: To remove unionfs-fuse package use the command.

sudo apt-get remove unionfs-fuse 

Step 7: To remove the unionfs-fuse package and it’s dependant package use the command.

sudo apt-get remove --auto-remove unionfs-fuse

Try out the all-new GeeksforGeeks Premium!

My Personal Notes arrow_drop_up
Recommended Articles
Page :