使用 rclone 挂载 OpenList WebDAV 网盘
目录
rclone 是一款强大的命令行云存储同步工具。我们可以通过 rclone 将支持 WebDAV 的网盘(如 openList、Nextcloud 等)挂载到本地目录,像操作本地文件一样使用。
本文将介绍如何在 Linux 下安装 rclone、配置 WebDAV 连接、挂载网盘,并设置开机自动挂载。
一、安装 rclone #
rclone 可以通过官方脚本安装,也可以使用系统的包管理器。镜像安装需要额外处理路径映射,较为繁琐,因此本文采用 apt 直接安装。
1. 安装依赖 fuse #
sudo apt update
# 查看是否已安装 fuse3
sudo apt search fuse3
# 若未安装,则执行(libfuse3-x 中的 x 替换为上一步搜索结果中的具体版本号)
sudo apt install fuse3 libfuse3-x
2. 安装 rclone #
sudo apt install rclone
3. 验证安装 #
which rclone
如果输出 /usr/bin/rclone 等路径,说明安装成功。
二、配置 rclone(以 WebDAV 为例) #
有两种配置方式:交互式配置或直接编辑配置文件。
方式一:使用 rclone config 交互配置 #
- 执行命令:
rclone config
- 按提示操作(以下为关键步骤):
n) New remote # 选择 n 新建远程
name> your-remote # 输入自定义名称,下文以 your-remote 为例
Storage> webdav # 选择 webdav 类型
url> https://your-domain.com/dav # 填写 WebDAV 地址,如果你的openlist是本地内网安装,注意修改为http://ip:port/dav,必须包含 /dav
vendor> other # 选择 other(不在预置列表中)
user> your-username # 填写用户名
password: (输入密码) # 选择 y 手动输入
bearer_token> (直接回车)
Edit advanced config? n
y) Yes this is OK
- 完成后退出。
方式二:直接编辑配置文件 #
配置文件位于 ~/.config/rclone/rclone.conf(若不存在则创建):
[your-remote]
type = webdav
url = https://your-domain.com/dav
vendor = other
user = your-username
pass = your-encrypted-password
如果已有配置但需要更新密码,可以用命令:
rclone config update your-remote pass "你的明文密码"
实际保存时 rclone 会自动加密密码,无需手动加密。
三、测试配置是否成功 #
rclone lsd your-remote:
如果正常返回远程目录列表(例如):
-1 2026-03-31 15:32:00 -1 115ND
-1 2026-03-31 15:32:00 -1 localStorage
-1 2026-03-31 15:32:00 -1 quark
则表示配置成功。否则请检查 URL、用户名和密码。
四、挂载网盘到本地目录 #
1. 创建挂载点 #
mkdir -p ~/NetDisk/115
2. 执行挂载命令 #
rclone mount your-remote:/115ND ~/NetDisk/115 \
--copy-links \
--no-gzip-encoding \
--allow-non-empty \
--umask 000 \
--use-mmap \
--daemon
参数说明:
-
--daemon:后台运行,不会占用当前终端。 -
your-remote:/115ND:远程目录(可根据实际修改)。 -
--allow-non-empty:允许挂载到非空目录。 -
--umask 000:开放所有用户的读写权限(根据安全需求调整)。
3. 检查挂载状态 #
df -h
输出类似:
your-remote:115ND 1.0T 0 1.0T 0% /home/your-user/NetDisk/115
表示挂载成功。
4. 解除挂载 #
fusermount -qzu ~/NetDisk/115
五、设置开机自动挂载(systemd –user) #
手动挂载重启后会失效。我们可以通过 systemd 用户服务实现开机自动挂载。
1. 创建服务文件 #
mkdir -p ~/.config/systemd/user
vim ~/.config/systemd/user/rclone-115.service
内容如下:
[Unit]
Description=Rclone Mount for 115ND
After=network-online.target
[Service]
ExecStart=/usr/bin/rclone mount your-remote:/115ND /home/your-user/NetDisk/115 \
--copy-links --no-gzip-encoding --allow-non-empty --umask 000 --use-mmap
ExecStop=/usr/bin/fusermount -qzu /home/your-user/NetDisk/115
Restart=on-failure
Type=simple
[Install]
WantedBy=default.target
注意:服务中不要加
--daemon,因为 systemd 会管理进程的前后台。
2. 启用并启动服务 #
systemctl --user daemon-reload
systemctl --user enable rclone-115.service
systemctl --user start rclone-115.service
3. 验证服务状态 #
systemctl --user status rclone-115.service
之后每次开机,网盘都会自动挂载到指定目录。