Open In App

How to Transparently Overlaid Two Directories Using UnionFS in Linux?

Last Updated : 30 Sep, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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 dependent package use the command. 

 

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

 


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads