ln -s vs mount --bind
First ,Symlinks and bind mounts are a whole different ballgame.
ln -s you create a symbolic link,which is an inode pointing to a certain filesystem object.
If you mount a filesystem with --bind, you create a second mountpoint for a device or filesystem.
If you envision a symlink as a redirect, then envision a --bind mounted filesystem as creating another gateway to data.
The --bind mount seems a bit more robust to me and it probably is a bit faster than working with a symlink.
a symlink is visible in an ls,whereas a bind mount is only visible when looking at /proc/mounts or /etc/mtab (which is what the mount command does, if it is executed without parameters).
One of the big differences between ln -s and a bind mount is that you can use a bind mount to "modify" a read-only filesystem.
For example, if there were a CD mounted on /mnt/application, and you wanted to replace /mnt/application/badconfigfile.conf with a correct version, you could do this:
mount -o bind /path/to/correct/file.conf /mnt/application/badconfigfile.conf
It would not be possible to affect the same change using a symlink because you're not able to modify the target filesystem. This can also be used to good affect if you distributed a common suite of software via NFS (or some sort of cluster filesystem), and you want to make host-specific changes on one system. You can simply use a bind mount on the target system to override the files or directories as necessary.
Practial difference #1 for me between ln -s and mount --bind :
vsftpd doesn't not allow to browse a directory through a symbolic link, but allows when mounted
One might note that as a consequence of binding to a mount, which is itself a binding, that is later rebound, the original binding remains intact, assuming everything physically stay connected.
That is, if bind A to B and bind B to C, and then bind D to B, C will still be bound to A. That might be what you want, or not. If one desires C to follow B then remount using the same targets, i.e. mount -o remount B C, or use --rbind instead. There is no --rebind option.
mount, when invoked without any arguments, prints the contents of /etc/mtab, which has slightly different information than /proc/mounts. (In particular, /proc/mounts (symlink to /proc/self/mounts) always shows the mountpoints visible to the process reading it.) –
ln -s vs mount --bind的更多相关文章
- mount --bind 重启后失效的解决办法
vsftp不支持软链接,可以用mount来支持不同的目录结构 mount --bind /home/www/web/ROOT/img/upload /ftp/private/upload 重启后失效. ...
- mount --bind使用方法
我们可以通过mount --bind命令来将两个目录连接起来,mount --bind命令是将前一个目录挂载到后一个目录上,所有对后一个目录的访问其实都是对前一个目录的访问,如下所示: ## test ...
- mount --bind 的妙用
在固件开发过程中常常遇到这样的情况:为测试某个新功能,必需修改某个系统文件.而这个文件在只读文件系统上(总不能为一个小小的测试就重刷固件吧),或者是虽然文件可写,但是自己对这个改动没有把握,不愿意 ...
- mount --bind
[root@iZwz9i55e7v33yn8ksnh8nZ ~]# mkdir /tmp/dir1 [root@iZwz9i55e7v33yn8ksnh8nZ ~]# mkdir /tmp/dir2 ...
- mount --bind绑定命令
将目录或文件DirFile-1绑定到目录或文件DirFile-2上,所有对DirFile-2的访问就是对DirFile-1的访问 mount --bind [DirFile-1] [DirFile-2 ...
- 查看一个目录是否已经mount --bind
执行 mountpoint -q /test/mount echo $? 如果是0表示已经mount mountpoint -q /test/mount || mount -o bind /some/ ...
- Data Volume 之 bind mount - 每天5分钟玩转 Docker 容器技术(39)
storage driver 和 data volume 是容器存放数据的两种方式,上一节我们学习了 storage driver,本节开始讨论 Data Volume. Data Volume 本质 ...
- 37-Data Volume 之 bind mount
storage driver 和 data volume 是容器存放数据的两种方式,上一节我们学习了 storage driver,本节开始讨论 Data Volume. Data Volume 本质 ...
- Bind Mounts and File System Mount Order
When you use the bind option of the mount command, you must be sure that the file systems are m ...
随机推荐
- Apache2.4的三种模式
prefork 多进程模式 一个主进程,负责生成多个子进程,也称工作进程,进程之间独立,每个进程之间只能有一个线程,优点是稳定,缺点是内存占用大,每个进程响应一个用户请求. worker 多线程模式 ...
- Python中列表,元组,字典,集合的区别
参考文档https://blog.csdn.net/Yeoman92/article/details/56289287 理解Python中列表,元组,字典,集合的区别 列表,元组,字典,集合的区别是p ...
- DB2中的NVL和NVL2函数
NVL函数是一个空值转换函数 NVL(表达式1,表达式2) 如果表达式1为空值,NVL返回值为表达式2的值,否则返回表达式1的值. 该函数的目的是把一个空值(null)转换成一个实际的值.其表达式的值 ...
- js 高级程序设计 第四章学习笔记
问题:怎么才能形象的理解堆栈空间? 1. 声明变量 使用 var 声明的变量会自动被添加到最接近的环境中.在函数内部,最接近的环境就是函数的局部 环境:在 with 语句中,最接近的环境是函数环境.如 ...
- Jenkins占用内存较大解决办法
主机启动jenkins后导致内存占用较大 登录主机top按键M按消耗内存排序 未调优前查看进程 修改配置文件 /usr/local/jenkins-tomcat/bin/catalina.sh 增加一 ...
- iOS技术面试04:数据存储
如果后期需要增加数据库中的字段怎么实现,如果不使用CoreData呢? 编写SQL语句来操作原来表中的字段 1> 增加表字段 ALTER TABLE 表名 ADD COLUMN 字段名 字段类型 ...
- 上下文管理器之__enter__和__exit__
目录 前言 with as是如何工作的 自定制open方法 更多的示例 返回主目录 前言 回到顶部 有个学生在第四轮面试中被CTO问到:如何自定义实现with open的功能.然后就一脸懵逼的回来找我 ...
- IBM.WMQ订阅主题,连续获取消息解决办法
去队列里面一直获取消息,一开始想到了两种解决方案: 第一:订阅一次获取一次消息,正常的话每次都能获取到,但是要及时去清理订阅并且时间粒度不好控制 第二:订阅一次,再获取消息这里加死循环,超时MQ已经做 ...
- HTTP网页请求状态码
我们平时在打开一些网页的时候,会遇到打不开的情况,页面提示404错误,这个404就是http状态码.如果我们可以正常打开网页,这时也会有http状态码的,这个状态码就是200,只不过这时我们是无法通过 ...
- 泛微E-cology OA /weaver/ 代码执行漏洞
泛微E-cology OA /weaver/代码执行漏洞 泛微e-cology OA Beanshell组件远程代码执行 分析文章:https://dwz.cn/bYtnsKwa http://127 ...