Pro Tip: Mount a Local Folder Instead of Symlinking it
Pro Tip: Mount a Local Folder Instead of Symlinking it

Pro Tip: Mount a Local Folder Instead of Symlinking it

Although they are convenient, sometimes Symlinks just are not the right tool for the job. In certain circumstances you may want a directory to link to another transparently, without the OS being aware. Certain server software, for example, will not follow symlinks. Whatever the reason, sometimes you want something more substantial. This is where mounting with the --bind comes in handy. It looks like this:

# mkdir /path/to/dest
# mount /path/to/src --bind /path/to/dest

The result is a directory mounted as though it were an external file system. The only difference is that it happens to be another local directory. If you want this directory mounted by default every time you boot up your computer, put the following line in your /etc/fstab file:

/path/to/src /path/to/dest none bind 0 0

There you have it. Now you may browse that directory with all of the freedom of a symbolically linked one without the shame or discomfort.

Leave a Reply

Your email address will not be published. Required fields are marked *