How to Transparently Overlaid Two Directories Using UnionFS in Linux?

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


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

2


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.