Mounting A Directory in Two or More Places without copying (for Linux)
on Saturday 1st September, 2007 Gabe speculated thusly…Have you ever wanted to show the contents of another user’s directory in a folder of your own? Or perhaps for whatever reason wanted to have the contents of a directory in two places at once, but without copying across? Well in Linux there is a way. Directories can be bound to other directories. The contents of one directory shows up in another, change one, and you change them both. Say for example you had the following directory /usr/home/fred but you wanted it to appear in Tom’s home directory also. First you need to create the destination folder that you will later bind the directory to:
mkdir /usr/home/tom/freds_folder
Now we use the mount command with the bind option to bind Fred’s folder in to the folder inside Tom’s home directory:
mount -o bind /usr/home/fred /usr/home/tom/freds_folder
Voilla! You now have the same folder in two locations. Just remember that the permissions will stay exactly the same.
Tags: guide, HowTo, Operating System