Score:1

Can we just use symbolic link instead of 'mount --bind'?

za flag

Recently I came to know about the mount --bind command but there is something that I can't understand clearly. Suppose I have a disk partition and I mounted it to a mount point /bkup using this command.

sudo mount /dev/sdd1 /bkup

If I want to make that /home/bkup directory appear as ~/bkup, I could do

sudo mount --bind /bkup ~/bkup

But how is it different from

ln -s /bkup ~/bkup

in effect? Why should I use mount --bind when I can do the same thing with ln -s command?

muru avatar
us flag
Does this answer your question? [What is the difference between ln -s and mount --bind?](https://askubuntu.com/questions/557733/what-is-the-difference-between-ln-s-and-mount-bind)
Score:1
cn flag
raj

mount --bind is more like an equivalent of a "hard link" to a directory (well, you cannot create hard links to directories, but this is closest you can get), while symbolic link is... well, a symbolic link.

Myself I found two cases where the difference may be important:

  1. running some service in a chroot. Symbolic links from inside a chroot jail to outside of a chroot jail don't work, while mount --bind works.

  2. sharing some directory over a network. You cannot share a symbolic link, but you can share directory mounted over mount --bind.

You must also be very careful with programs that by design distinguish between symbolic links and actual directories, like rsync. Trying to run rsync on a symbolic link to a directory may give you completely other results than you expect.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.