Windows 端
下载安装
- rclone : https://rclone.org/downloads/
- winfsp : http://www.secfs.net/winfsp/download/
配置
rclone config
- Google drive 用或不用添加API,获取API地址
- OneDrive 不用获取API
- 所有步骤选择默认即可,会弹出授权网站页面
挂载
rclone mount drive_name:/ N: --cache-dir D:\Temp --vfs-cache-mode writes
vfs-cache-mode选择
off
: In this mode the cache will read directly from the remote and write directly to the remote without caching anything on disk. (本地不做任何缓存,所有文件直接从云端获取并写入。建议网速特别好时(复制粘贴大文件时建议至少100M管以上速度)使用。minimal
: This is very similar to “off” except that files opened for read AND write will be buffered to disks. This means that files opened for write will be a lot more compatible, but uses the minimal disk space. (和off类似,但是已经打开的文件会被缓存到本地。个人推荐,小文件基本够用,但是如果你的网络情况(梯子)不是特别好的话,用writes也行writes
: In this mode files opened for read only are still read directly from the remote, write only and read/write files are buffered to disk first. (如果文件属性为只读则只从云端获取,不然先缓存在本地进行读写操作,随后被同步。个人推荐使用,但是在直接从本地复制文件到GDrive时还是看网络情况full
:In this mode all reads and writes are buffered to and from disk. When a file is opened for read it will be downloaded in its entirety first. (所有的读写操作都会缓存到磁盘中。然后才会同步。不是很推荐。会导致所有文件均被缓存到本地。直到达到你缓存总额(—cache-total-chunk-size,默认大小10G)。但是你网速特别差时也可以使用。
后端运行以及开机自动挂载
- 新建VBS命令(.vbs文件)
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 mount drive_name:/ N: --cache-dir D:\Temp --vfs-cache-mode writes", 0
end if
- 复制到开机启动文件夹
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Linux端
安装
curl https://rclone.org/install.sh | sudo bash
配置
- Onedrive 需要先在Windows端获取token,按照以上步骤操作后会出现token,形如
{"access_token":"EwBwA8l6.............$","expiry":"2019-11-07T22:30:23.7582+08:00"}
- 复制保存,再到Linux端操作
rclone config
- Google drive 用或不用添加API,获取API地址
- OneDrive 不用获取API
- 其他步骤选择默认即可,但是
Use auto config
一步应选择n
,这时,Google Drive会出现一个网址,访问授权后可获得一个key,复制到终端;Onedrive会提示输入token,粘贴Windows端获得的token;
挂载
rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-non-empty --allow-other --umask=000"
# 若需要指定用户,例如 "www",在 "/etc/passwd/" 中找到用户GID和UID,使用命令
rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-non-empty --allow-other --umask=000 --uid=UID --gid=GID"
# 若要挂载供多媒体应用使用,以下为优化
rclone mount DriveName:Folder LocalFolder \
--umask 000 \
--default-permissions \
--allow-non-empty \
--allow-other \
--buffer-size 32M \
--dir-cache-time 12h \
--vfs-read-chunk-size 64M \
--vfs-read-chunk-size-limit 1G \
--uid=UID \
--gid=GID
开机自启
cat > /etc/systemd/system/rclone.service <<EOF
[Unit]
Description=Rclone
After=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-non-empty --allow-other --umask=000"
Restart=on-abort
User=root
[Install]
WantedBy=default.target
EOF
systemctl start rclone
systemctl enable rclone
卸载
fusermount -u /path/
Lasted update: May 27, 2020 at 10:58 pm