difference between hardlink and bind mount?
Asked Answered
F

2

16

it might be a stupid question but:

http://dwaves.de/2015/05/26/linux-search-find-files-locate-find-linux-locate-scope/

bind mounts under linux:

as far as i understand it: you can mount the same dir in two different places.

but where is the difference to hardlinks?

The bind mounts. Since Linux 2.4.0 it is possible to remount part of the file hierarchy somewhere else. The call is:

mount –bind olddir newdir

is it just another way of making a folder accessible? (but its not actually using any network protocol because it's all local)

please provide some examples pros/cons.

thanks :)

Freetown answered 26/5, 2015 at 9:7 Comment(4)
sry this link: dwaves.de/2015/05/26/linux-bind-mountsFreetown
"bindmounts" are just simple "mounts"? nothing special?Freetown
This question is a more general computing question than it is programming-related so it’s off-topic for StackOverflow. You’d have a much better chance of getting good answers at Unix and Linux or Ask Ubuntu if you’re running Ubuntu. BTW, it's better to improve your question by editing it rather than adding comments. See also stackoverflow.com/help/how-to-askSp
i was searching for the edit button for quite a while... today (3 days later) i found it... its that little grey something on the white background... okay :-DFreetown
A
15

In general hard link is filesystem object, mount point - is kernel entity. Hardlink will persistent during reboot, mount point - isn't.

Apophyllite answered 26/5, 2015 at 10:5 Comment(3)
okay so bind-mounts are just "mounts" - not persistant etc. pp. i cannot vote your answer up but thx :)Freetown
You can make it persistent if you put it on /etc/rc.local which reruns the command on reboot.Bagwig
bind mount can be persistent if you add it to /etc/fstabKesselring
A
13

The difference is that mount --bind works. Linux does not allow you to create hard links to directories.

Modern OS generally don't allow the manual creation of directory hard links because this can result in hard-to-detect cycles that would cause most recursive programs to choke. Such issues could enable DoS attacks and exploitable crashes.

mount --bind allows the same functionality, but in a safe way. Any directory mounted under itself will simply appear empty when you try to recurse into it, thereby breaking any such cycles.

You can also mount --bind individual files. In this case, the difference is that mount --bind works across filesystems.

Abrogate answered 14/8, 2018 at 17:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.