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
- Linux Virtualization : Linux Containers (lxc)
- SED command in Linux | Set 2
- od command in Linux with example
- while command in Linux with example
- Fun Commands in Linux
- who command in Linux
- The Linux Kernel
- Linux Commands
- Linux | Nmon
- Different Shells in Linux
- du Command in LINUX
- Permissions in Linux
- 10 Best Linux VPS Hosting
- 'dd' command in Linux
- Run Levels in Linux
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. 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.