树莓派搭建NAS之四:rclone挂载openList

背景

openList挂载网盘之后,只能在web页面上进行同步文件,在omv和openList上都无法创建定时同步任务。自己动手,丰衣足食。 开搞开搞~~~~

调研

先整理一下我的诉求:

  • 将本地文件同步到openList中
  • 增量同步,已有文件可以跳过
  • 定时执行:1个小时同步一次。

通过调研发现,可以通过rclone将openList挂载到本地,成为一个本地盘。openList成为本地盘之后,完全可以使用rsync、rclone等工具写个脚本将一个磁盘的文件写入到另外一个磁盘,简单方便很多。

安装rclone

rclone可以支持镜像安装和apt安装方式,镜像安装方式需要将路径来回进行映射,较为麻烦。故而选择直接安装较为简单

安装依赖fuse

sudo apt update
sudo apt install fuse3 libfuse3-dev

安装rclone

sudo apt-get install rclone

检查是否安装成功:

which rclone

回显显示具体路径 /usr/bin/rclone 表示安装成功

配置rclone

方式一:使用rclone config配置

1、执行config

rclone config

2、选择配置项:
详细配置内容见:https://rclone.org/webdav/

rclone config
2025/10/03 11:10:13 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> openList
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 .....
27 / Transparently chunk/split large files
   \ "chunker"
28 / Union merges the contents of several remotes
   \ "union"
29 / Webdav
   \ "webdav"
30 / Yandex Disk
   \ "yandex"
.....
Storage> webdav
** See help for webdav backend at: https://rclone.org/webdav/ **

URL of http host to connect to
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / Connect to example.com
   \ "https://example.com"
url> http://192.168.1.4:5244/dav 
Name of the Webdav site/service/software you are using
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
 1 / Nextcloud
   \ "nextcloud"
 2 / Owncloud
   \ "owncloud"
 3 / Sharepoint
   \ "sharepoint"
 4 / Other site/service or software
   \ "other"
vendor> 4
User name
Enter a string value. Press Enter for the default ("").
user> xxx
Password.
y) Yes type in my own password
g) Generate random password
n) No leave this optional password blank
y/g/n> y
Enter the password:
password:
Confirm the password:
password:
Bearer token instead of user/pass (eg a Macaroon)
Enter a string value. Press Enter for the default ("").
bearer_token> 
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n
Remote config
--------------------
[openList]
url = http://192.168.1.4:5244/dav
vendor = other
user = xxxx
pass = *** ENCRYPTED ***
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:

Name                 Type
====                 ====
openList             webdav

配置介绍:

  1. n/s/q> n 表示新建
  2. name> openList 输入自定义名称,之后可以使用这个名称进行操作
  3. Storage> webdav openList可以通过webdev方式进行挂载,
  4. vendor> 4 选择other,openList不在rclone的webdav的配置列表中
  5. url> http://192.168.1.4:5244/dav 配置openList连接,必须携带/dav,不然会配置不出来
  6. user> xxx 输入openList中的用户名和密码,用于连接openList
  7. bearer_token> 直接回车,跳过即可
  8. Edit advanced config? (y/n) 选择n,不配置高级设置
  9. 配置完直接退出即可

方式二:直接更改配置文件

vim ~/.config/rclone/rclone.conf

[openList]
type = webdav
url = http://localhost:5244/dav
vendor = Other
user = <用户名>
pass = <密码,密码是需要加密的>

重新更新密码:

rclone config update openList pass {用户密码}

测试rclone是否成功

rclone lsd openList

回显显示:

-1 2025-10-02 11:40:46        -1 aliyunpan
-1 2025-10-02 11:49:24        -1 local
-1 2025-10-02 11:52:35        -1 smb-local

表示已经成功配置,否则需要重新检查配置是否正常

rclone 挂载openList网盘

挂载命令:

rclone mount openList:/ /mnt/aliyun --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --use-mmap --daemon
  • <code>--daemon</code>: 为挂载后台运行,否则挂载的命令窗口会一直处于运行中
  • <code>openList:/</code>: 为挂载的openList的路径,也可以写成子路径形式<code>openList:/aliyunpan</code>

检查是否挂载成功:

df -h

回显显示:

openlist:aliyunpan  1.0P     0  1.0P   0% /mnt/aliyun

表示挂载成功

解除挂载命令

fusermount -qzu /mnt/aliyunpan

设置rclone开机自动挂载

上面的手动挂载方式,在机器重启后,就失效了,每次都要手动在设置一遍,很麻烦。我们可以使用<code>service</code>文件来进行自动挂载。

创建service文件

vim /usr/lib/systemd/system/rclone.service

文件内容:

[Unit] 
Description=rclone 
After=docker.service network.target
Requires=docker.service

[Service] 
User=root 
ExecStart=/usr/bin/rclone mount openList:/ /mnt/aliyunpan  --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --use-mmap

[Install] 
WantedBy=multi-user.target

设置开机自启

systemctl daemon-reload
systemctl enable rclone.service
systemctl start rclone.service

参考文档