HomeGuest BlogsHow to Transparently Overlaid Two Directories Using UnionFS in Linux?

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

 

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

 

Last Updated :
30 Sep, 2022
Like Article
Save Article


Previous

<!–

8 Min Read | Java

–>


Next


<!–

8 Min Read | Java

–>

Share your thoughts in the comments

RELATED ARTICLES

45 COMMENTS

Most Popular

Dominic
32644 POSTS0 COMMENTS
Milvus
131 POSTS0 COMMENTS
Nango Kala
7020 POSTS0 COMMENTS
Nicole Veronica
12155 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12253 POSTS0 COMMENTS
Shaida Kate Naidoo
7151 POSTS0 COMMENTS
Ted Musemwa
7416 POSTS0 COMMENTS
Thapelo Manthata
7108 POSTS0 COMMENTS
Umr Jansen
7114 POSTS0 COMMENTS