安装rclone

使用 Linux 自带的 apt/yum/dnf 等皆可, 或者使用 rclone 官方安装脚本

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

设置 rclone

1
2
3
4
$ which rclone
/usr/bin/rclone

$ ln -s /usr/bin/rclone /sbin/mount.rclone

配置 systemd

  1. 在 /etc/systemd/system/ 路径下创建 .mount 文件

假设挂在路径为 /mnt/mount, 则文件名为 mnt-mount.mount

  1. 按以下内容修改
1
2
3
4
5
6
7
[Unit]
After=network-online.target
[Mount]
Type=rclone
What=<挂载的盘名> # onedrive:
Where=<挂载路径> # /mnt/mount
Options=rw,allow_other,args2env,vfs-cache-mode=writes,config=<rclone.conf路径>,cache-dir=/var/rclone
  1. 挂载
1
2
3
4
# 重载配置文件
$ systemctl daemon-reload

$ systemctl start mnt-mount.mount
  1. 开机自启,自动挂载[可选]
  • 同路径下新增一个同名前缀,后缀automount的文件,例如mnt-mount.automount
1
2
3
4
5
6
7
8
[Unit]
After=network-online.target
Before=remote-fs.target
[Automount]
Where=<挂载路径> # /mnt/mount
TimeoutIdleSec=600
[Install]
WantedBy=multi-user.target
  • 启动方式改为 systemctl start mnt-mount.automount

automount将会通过同名 mount 进行挂载,无需start .mount

1
systemctl enable mnt-mount.automount	#开机自启