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.) –

  • 相关阅读:
    程序员创业必读的几本书
    新手上路—Java的"瑞士军刀"
    小团队互联网创业记
    Coder必须自废的两样神功
    码界新手,如何更高效的解决问题
    【转载】FckEditor 2.6.3 for Java 2.4 配置
    struts2上传多文件(b)
    Java基础-Java中的Calendar和Date类
    JAVA加减日期
    Java程序员应该了解的10个面向对象设计原则
  • 原文地址:https://www.cnblogs.com/linuxbo/p/4303650.html
Copyright © 2011-2022 走看看