使用Rclone和WinFsp挂载FTP为磁盘

介绍

Rclone:是一款的命令行工具,支持在不同对象存储、网盘间同步、上传、下载数据。官网网址:rclone.org

WinFsp:是一款Windows平台下的文件系统代理软件(Windows File System Proxy)。类似FUSE (Filesystem in Userspace)。官网网址: secfs.net/winfsp

使用

1、下载WinFsp,如我下载的是winfsp-1.4.19016.msi,下一步下一步安装就行。

2、解压rclone,运行:

rclone.exe config

我配置的是FTP,按步骤填IP账号密码,最后Quit config就行。

3、运行类似如下指令挂载:

rclone.exe mount PC2:/ X: –cache-dir D:\logs_rcloneCache –vfs-cache-mode writes

其中PC2是上一步rclone配置的名字,X:是挂载的本地磁盘位置,注意不要在最后加上/,D:\logs_rcloneCache是缓存的位置,默认会在C:\Users\用户名\AppData\Local\rclone这里,后面的writes是缓存模式。效果如下:

也可以挂载为目录:

rclone.exe mount PC2:/ C:\intel\2 –cache-dir D:\logs_rcloneCache –vfs-cache-mode writes

之后就可以当正常盘使用啦。几种缓存模式可参考官方文档R酱的博文有中文说明,他举例的是挂载网盘,也可以尝试。

R酱还提到一种开机自动挂载的方式,参考脚本如下:

Option Explicit

Dim WMIService, Process, Processes, Flag, WS

Set WMIService = GetObject("winmgmts:{impersonationlevel=impersonate}!\\.\root\cimv2")

Set Processes = WMIService.ExecQuery("select * from win32_process")

Flag = true

for each Process in Processes

    if strcomp(Process.name, "rclone.exe") = 0 then

        Flag = false

        exit for

    end if

next

Set WMIService = nothing

if Flag then

    Set WS = Wscript.CreateObject("Wscript.Shell")

    WS.Run "rclone.exe mount PC2:/ C:\intel\1 --cache-dir D:\logs\_rcloneCache --vfs-cache-mode writes", 0

end If

参考文档

https://blog.rhilip.info/archives/874/

https://www.nozarc.com/2018/01/21/kodcloud-rclone/