Rclone挂载OneDrive

发布于 2020-10-27  840 次阅读


本地授权Rclone

在本地Windows电脑下载并解压Rclone,下载地址:

https://rclone.org/downloads/

用cmd进入解压好的文件夹

cd C:\xx\rclone

并执行以下命令:

rclone authorize "onedrive"

在弹出网页中登录OneDrive相关账号并授权后,cmd中会自动获取code,其中请复制{"access_token"...}中全部内容。

VPS安装Rclone

运行:

curl https://rclone.org/install.sh | bash

配置Rclone

rclone config

一路根据提示填,注意:

Remote config
Use auto config?
Say Y if not sure
Say N if you are working on a remote or headless machine
y) Yes
n) No
y/n> n # 选n

随后粘贴{"access_token"...}中全部内容,包括大括号本身也要粘贴。

VPS挂载Onedrive

安装fuse

Debian:

apt-get update && apt-get install -y fuse 

CentOS:

yum install -y fuse

挂载磁盘

#新建本地文件夹,路径自己定,即下面的LocalFolder
mkdir /root/OneDrive
#挂载为磁盘,下面的DriveName、Folder、LocalFolder参数根据说明自行替换
rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --vfs-cache-mode writes --umask 000 --daemon

DriveName为初始化配置填的name,Folder为OneDrive里的文件夹,LocalFolder为VPS上的本地文件夹。例如:

rclone mount E5Share:/ /root/E5Share --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --vfs-cache-mode writes --umask 000 --daemon

如果挂载过程中出现NOTICE: One drive root 'test': poll-interval is not supported by this remote错误,可以无视该错误。

挂载成功后,输入df -h命令查看即可。

卸载磁盘

fusermount -qzu LocalFolder

设置开机启动

command="mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --vfs-cache-mode writes --umask 000 --daemon"

例如:

command="mount E5Share:/ /root/E5Share --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --vfs-cache-mode writes --umask 000 --daemon"
cat > /etc/systemd/system/rclone1.service <<EOF
[Unit]
Description=Rclone
After=network-online.target

[Service]
Type=simple
ExecStart=$(command -v rclone) ${command}
Restart=on-abort
User=root

[Install]
WantedBy=default.target
EOF
#设置开机自启
systemctl enable rclone1
#重启:
systemctl restart rclone1
#停止:
systemctl stop rclone1
#状态:
systemctl status rclone1

如果要挂载多个网盘,那么将systemd配置文件的rclone1.service改成rclone2.service即可,重启动什么的同样换成rclone2。


Love is merely a madness.