vsftpd服务器不支持软连接?但是支持本机不同目录挂载?(貌似支持软连接)

Posted Dontla

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vsftpd服务器不支持软连接?但是支持本机不同目录挂载?(貌似支持软连接)相关的知识,希望对你有一定的参考价值。

ps. 谁说不支持软连接啊,我测试过支持软连接啊,vsftpd能把文件上传到一个软连接目录下,下载没测试


以下为转载内容:

vsftpd本身不支持软连接,而在用FTP共享的时候又不想移动文件位置,便在网上找到了一个workaround:

Linux内核从2.4.0开始支持把一部分文件系统挂载到文件系统中的其他位置,mount命令的--bind选项正好提供了这个功能。通过命令

mount --bind "/path/to/share" "/path/of/ftp/subpath"
可以把需要共享的文件夹“/path/to/share”挂载到FTP目录中的一个子目录上“/path/of/ftp/subpath”。这个目录对于vsftpd而言是一个正常文件系统的目录,于是就可以被共享了。当不需要共享目录时,直接umount即可,就使用而言,不比link麻烦多少。

mount --bind”命令本身支持单个文件的挂载,可以把目标文件挂载到另外一个文件上,起到类似于软链接的功能。同目录的挂载类似,这也是vsftpd支持的。

综上,可以说除了需要权限外,使用mount已经可以解决vsftpd不支持软链接的问题了

参考文章1:vsftpd不支持目录软链接的解决办法

mount和umount命令的帮助提示

mount

root@ubuntu:/home/ftp/ky# mount -h

Usage:
 mount [-lhV]
 mount -a [options]
 mount [options] [--source] <source> | [--target] <directory>
 mount [options] <source> <directory>
 mount <operation> <mountpoint> [<target>]

Mount a filesystem.

Options:
 -a, --all               mount all filesystems mentioned in fstab
 -c, --no-canonicalize   don't canonicalize paths
 -f, --fake              dry run; skip the mount(2) syscall
 -F, --fork              fork off for each device (use with -a)
 -T, --fstab <path>      alternative file to /etc/fstab
 -i, --internal-only     don't call the mount.<type> helpers
 -l, --show-labels       show also filesystem labels
 -n, --no-mtab           don't write to /etc/mtab
     --options-mode <mode>
                         what to do with options loaded from fstab
     --options-source <source>
                         mount options source
     --options-source-force
                         force use of options from fstab/mtab
 -o, --options <list>    comma-separated list of mount options
 -O, --test-opts <list>  limit the set of filesystems (use with -a)
 -r, --read-only         mount the filesystem read-only (same as -o ro)
 -t, --types <list>      limit the set of filesystem types
     --source <src>      explicitly specifies source (path, label, uuid)
     --target <target>   explicitly specifies mountpoint
 -v, --verbose           say what is being done
 -w, --rw, --read-write  mount the filesystem read-write (default)
 -N, --namespace <ns>    perform mount in another namespace

 -h, --help              display this help
 -V, --version           display version

Source:
 -L, --label <label>     synonym for LABEL=<label>
 -U, --uuid <uuid>       synonym for UUID=<uuid>
 LABEL=<label>           specifies device by filesystem label
 UUID=<uuid>             specifies device by filesystem UUID
 PARTLABEL=<label>       specifies device by partition label
 PARTUUID=<uuid>         specifies device by partition UUID
 <device>                specifies device by path
 <directory>             mountpoint for bind mounts (see --bind/rbind)
 <file>                  regular file for loopdev setup

Operations:
 -B, --bind              mount a subtree somewhere else (same as -o bind)
 -M, --move              move a subtree to some other place
 -R, --rbind             mount a subtree and all submounts somewhere else
 --make-shared           mark a subtree as shared
 --make-slave            mark a subtree as slave
 --make-private          mark a subtree as private
 --make-unbindable       mark a subtree as unbindable
 --make-rshared          recursively mark a whole subtree as shared
 --make-rslave           recursively mark a whole subtree as slave
 --make-rprivate         recursively mark a whole subtree as private
 --make-runbindable      recursively mark a whole subtree as unbindable

For more details see mount(8).

umount

root@ubuntu:/home/ftp/ky# umount -h

Usage:
 umount [-hV]
 umount -a [options]
 umount [options] <source> | <directory>

Unmount filesystems.

Options:
 -a, --all               unmount all filesystems
 -A, --all-targets       unmount all mountpoints for the given device in the
                           current namespace
 -c, --no-canonicalize   don't canonicalize paths
 -d, --detach-loop       if mounted loop device, also free this loop device
     --fake              dry run; skip the umount(2) syscall
 -f, --force             force unmount (in case of an unreachable NFS system)
 -i, --internal-only     don't call the umount.<type> helpers
 -n, --no-mtab           don't write to /etc/mtab
 -l, --lazy              detach the filesystem now, clean up things later
 -O, --test-opts <list>  limit the set of filesystems (use with -a)
 -R, --recursive         recursively unmount a target with all its children
 -r, --read-only         in case unmounting fails, try to remount read-only
 -t, --types <list>      limit the set of filesystem types
 -v, --verbose           say what is being done
 -q, --quiet             suppress 'not mounted' error messages
 -N, --namespace <ns>    perform umount in another namespace

 -h, --help              display this help
 -V, --version           display version

For more details see umount(8).

测试

查看挂载:

df -h

在CQ 119服务器上:

挂载:

# 前者是被链接者,后者是路径入口
mount --bind "/data/ky/" "/home/ftp/ky/"

取消挂载:

umount /home/ftp/ky/

测试发现,确实是可以实现同主机不同目录挂载的,挂载后,挂载入口路径下面之前的目录和文件就看不到了,直接就链到被挂载目录去了(而且看不出被挂载目录路径,不像软链接)

但是挂载后,我不知道怎么查找已挂载目录,,,,用df -h也查不到,这就有点蛋疼

参考文章2:mount --bind使用方法

以上是关于vsftpd服务器不支持软连接?但是支持本机不同目录挂载?(貌似支持软连接)的主要内容,如果未能解决你的问题,请参考以下文章

一则VSFTPD非本机连接慢问题排查与处理

Vsftpd服务

Linux系统对从Windows中共享过来的文件,不支持创建软连接的解决办法。

设置tomcat支持软连接

配置tomcat对软连接的支持

linux 软连接和硬链接的区别