[教程]用Rclone在Linux VPS上挂载网盘使用 @[TOC]
安装 官网:https://rclone.org
下载地址:https://downloads.rclone.org
1 2 curl https://rclone.org/install.sh | sudo bash
配置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 rclone config Current remotes: Name Type ==== ==== n) New remote d) Delete remote r) Rename remote c) Copy remote s) Set configuration password q) Quit config n/d/r/c/s/q> 1 / Amazon Drive \ "amazon cloud drive" 2 / Amazon S3 (also Dreamhost, Ceph, Minio) \ "s3" 3 / Backblaze B2 \ "b2" 4 / Box \ "box" 5 / Dropbox \ "dropbox" 6 / Encrypt/Decrypt a remote \ "crypt" 7 / FTP Connection \ "ftp" 8 / Google Cloud Storage (this is not Google Drive) \ "google cloud storage" 9 / Google Drive \ "drive" 10 / Hubic \ "hubic" 11 / Local Disk \ "local" 12 / Microsoft Azure Blob Storage \ "azureblob" 13 / Microsoft OneDrive \ "onedrive" 14 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH) \ "swift" 15 / QingClound Object Storage \ "qingstor" 16 / SSH/SFTP Connection \ "sftp" 17 / Yandex Disk \ "yandex" 18 / http Connection \ "http"
以onedrive for business为例,选择13,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 Microsoft App Client Id - leave blank normally. client_id> Microsoft App Client Secret - leave blank normally. client_secret> Remote config Choose OneDrive account type ? * Say b for a OneDrive business account * Say p for a personal OneDrive account b) Business p) Personal b/p> Use auto config? * Say Y if not sure * Say N if you are working on a remote or headless machine y) Yes n) No For this to work, you will need rclone available on a machine that has a web browser available. Execute the following on your machine: rclone authorize "onedrive" Then paste the result below: Name Type ==== ==== DriveName onedrive e) Edit existing remote n) New remote d) Delete remote r) Rename remote c) Copy remote s) Set configuration password q) Quit config e/n/d/r/c/s/q>
挂载:
1 2 3 4 5 6 7 8 rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 & NOTICE: One drive root 'DriveName' : poll-interval is not supported by this remote fusermount -qzu LocalFolder
客户端授权
Windows下运行
1 2 3 4 rclone authorize "onedrive"
在打开的浏览器中登陆账户
把命令行的access token输出结果复制到VPS中
常用命令 官方文档
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 rclone copy /home/backup gdrive:backup rclone copy gdrive:backup /home/backup rclone ls gdrive:backup rclone lsl gdrive:backup rclone lsd gdrive:backup rclone mkdir gdrive:backup rclone mount gdrive:mm /root/mm & fusermount -u /root/mm rclone cleanup remote:path rclone delete remote:path rclone rmdir rclone purge remote:path rclone sync source :path dest:path rclone config - 以控制会话的形式添加rclone的配置,配置保存在.rclone.conf文件中。 rclone copy - 将文件从源复制到目的地址,跳过已复制完成的。 rclone sync - 将源数据同步到目的地址,只更新目的地址的数据。 –dry-run标志来检查要复制、删除的数据 rclone move - 将源数据移动到目的地址。 rclone delete - 删除指定路径下的文件内容。 rclone purge - 清空指定路径下所有文件数据。 rclone mkdir - 创建一个新目录。 rclone rmdir - 删除空目录。 rclone check - 检查源和目的地址数据是否匹配。 rclone ls - 列出指定路径下所有的文件以及文件大小和路径。 rclone lsd - 列出指定路径下所有的目录/容器/桶。 rclone lsl - 列出指定路径下所有文件以及修改时间、文件大小和路径。 rclone md5sum - 为指定路径下的所有文件产生一个md5sum文件。 rclone sha1sum - 为指定路径下的所有文件产生一个sha1sum文件。 rclone size - 获取指定路径下,文件内容的总大小。. rclone version - 查看当前版本。 rclone cleanup - 清空remote。 rclone dedupe - 交互式查找重复文件,进行删除/重命名操作。
自启动 适用于Debian,使用方法: 1.复制内容,注意文本格式(UNIX). 2.将其重命名为rcloned(只要不是rclone就可以). 3.填好REMOTE和LOCAL,复制到/etc/init.d文件夹内. 4.运行初始化命令:bash /etc/init.d/rcloned init 5.使用 bash /etc/init.d/rcloned start 挂载. 6.使用 bash /etc/init.d/rcloned stop 卸载.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 #!/bin/bash PATH=/usr/local /sbin:/usr/local /bin:/sbin:/bin:/usr/sbin:/usr/bin REMOTE='' LOCAL='' CONFIG='/root/.config/rclone/rclone.conf' DEMO='rclone' [ -n "$REMOTE " ] || exit 1; [ -x "$(which fusermount) " ] || exit 1; [ -x "$(which $DEMO) " ] || exit 1; case "$1 " in start) ps -ef |grep -v grep |grep -q "$REMOTE " [ $? -eq '0' ] && { DEMOPID="$(ps -C $DEMO -o pid= |head -n1 |grep -o '[0-9]\{1,\}') " [ -n "$DEMOPID " ] && echo "$DEMO already in running.[$DEMOPID ]" ; exit 1; } fusermount -zuq $LOCAL >/dev/null 2>&1 mkdir -p $LOCAL rclone mount $REMOTE $LOCAL --config $CONFIG --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 >/dev/null 2>&1 & sleep 3; DEMOPID="$(ps -C $DEMO -o pid=|head -n1 |grep -o '[0-9]\{1,\}') " [ -n "$DEMOPID " ] && { echo -ne "$DEMO start running.[$DEMOPID ]\n$REMOTE --> $LOCAL \n\n" echo 'ok' >/root/ok exit 0; } || { echo "$DEMO start fail! " exit 1; } ;; stop) DEMOPID="$(ps -C $DEMO -o pid= |head -n1 |grep -o '[0-9]\{1,\}') " [ -z "$DEMOPID " ] && echo "$DEMO not running." [ -n "$DEMOPID " ] && kill -9 $DEMOPID >/dev/null 2>&1 [ -n "$DEMOPID " ] && echo "$DEMO is stopped.[$DEMOPID ]" fusermount -zuq $LOCAL >/dev/null 2>&1 ;; init) fusermount -zuq $LOCAL rm -rf $LOCAL ; mkdir -p $LOCAL ; chmod a+x $0 ; update-rc.d -f $(basename $0 ) remove; update-rc.d -f $(basename $0 ) defaults; rclone config; ;; esac exit 0
备注
没有安装fuse
1 2 3 4 5 6 7 8 Fatal error: failed to mount FUSE fs: fusermount: exec : "fusermount" : executable file not found in $PATH apt-get install fuse yum install fuse
OVZ VPS
配置文件存储位置
1 ~/.config/rclone/rclone.conf
参考链接 [ 教程 ] 在 Linux VPS 上利用 rclone 挂载 OneDrive 网盘
[ 教程 ] 在Linux VPS上使用 rclone 挂载 Google Drive 网盘
Rclone使用指南