zoukankan      html  css  js  c++  java
  • 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.) –

  • 相关阅读:
    reStructuredText学习
    PYTHON编码处理-str与Unicode的区别
    如何参与一个GitHub开源项目?
    Boost库编译安装
    git push失败the remote end hung up unexpectedly
    VBox虚拟机安装debian
    debian设置英文模式
    python 使用json.dumps() 的indent 参数添加缩进空格数,格式化字符串后输出
    unittest之装饰器 @classmethod
    jmeter正则提取信息头数据
  • 原文地址:https://www.cnblogs.com/linuxbo/p/4303650.html
Copyright © 2011-2022 走看看