Monday, May 13, 2024
55
rated 0 times [  55] [ 0]  / answers: 1 / hits: 40472  / 1 Year ago, thu, january 5, 2023, 12:36:08

I am trying to understand difference between using ln -s and mount --bind. In basic scenario I can use both to access one directory from somewhere else. In what scenarios those two will behave differently ?


More From » command-line

 Answers
7

They will behave differently in at least two cases:




  • In a chroot, if the link target is outside the chroot, the link will be dead. A bind mount will still be accessible.

  • Several programs can distinguish between symbolic links and actual directories or files. Few (if any) can distinguish between a directory or file and the one mounted on it. This also extends to symbolic links to something (A) which have something else (B) mounted on them. The link will show the contents of mount target (B) instead of the original (A).



Also, you can bind mount a directory or file on an existing directory or file, masking the original contents (rendering the original contents inaccessible unless the original was bind mounted elsewhere). A symbolic link requires that the original be moved or deleted.


[#22137] Friday, January 6, 2023, 1 Year  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
byishted

Total Points: 469
Total Questions: 113
Total Answers: 113

Location: Tajikistan
Member since Sun, Aug 29, 2021
3 Years ago
;