上文介绍了rclone挂载Google Drive,本文介绍挂载Onedrive,过程大同小异

本地下载Rclone

挂载 Onedrive 比 Google Drive 多一个步骤,需要首先在本地电脑上下载Rclone

下载 Windows 版的Rclone,地址:https://rclone.org/downloads/

下载后解压出来,比如我解压到H盘,文件夹命名rclone,此时按下Win+R,然后输入cmd,确定。再输入以下命令:

h:
cd h:\rclone
rclone authorize "onedrive"

回车后,浏览器会自动打开 Onedrive 登录页面,登录授权后,命令行窗口会出现一长串字符:

uudme-1577189884.jpg

你需要如上图一般,选中 {"access_token": ... }这一部分,点击一下右键复制,粘贴到记事本,稍后需要用到

VPS上安装Rclone

然后是在VPS上安装Rclone,一条命令解决:

# debian ubuntu
apt-get install wget -y && wget https://www.uud.me/usr/shell/rclone_debian.sh && bash rclone_debian.sh

# centos
curl https://rclone.org/install.sh | sudo bash

配置Rclone

输入命令:

rclone config

回车后,如下图:

root@debian:~# rclone config
Current remotes:

Name                 Type
====                 ====
gdrive               drive

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> n #新建
name> od1 #名称随便填
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
 1 / 1Fichier
   \ "fichier"
 2 / Alias for an existing remote
   \ "alias"
 3 / Amazon Drive
   \ "amazon cloud drive"
 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
   \ "s3"
 5 / Backblaze B2
   \ "b2"
 6 / Box
   \ "box"
 7 / Cache a remote
   \ "cache"
 8 / Citrix Sharefile
   \ "sharefile"
 9 / Dropbox
   \ "dropbox"
10 / Encrypt/Decrypt a remote
   \ "crypt"
11 / FTP Connection
   \ "ftp"
12 / Google Cloud Storage (this is not Google Drive)
   \ "google cloud storage"
13 / Google Drive
   \ "drive"
14 / Google Photos
   \ "google photos"
15 / Hubic
   \ "hubic"
16 / JottaCloud
   \ "jottacloud"
17 / Koofr
   \ "koofr"
18 / Local Disk
   \ "local"
19 / Mail.ru Cloud
   \ "mailru"
20 / Mega
   \ "mega"
21 / Microsoft Azure Blob Storage
   \ "azureblob"
22 / Microsoft OneDrive
   \ "onedrive"
23 / OpenDrive
   \ "opendrive"
24 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
   \ "swift"
25 / Pcloud
   \ "pcloud"
26 / Put.io
   \ "putio"
27 / QingCloud Object Storage
   \ "qingstor"
28 / SSH/SFTP Connection
   \ "sftp"
29 / Transparently chunk/split large files
   \ "chunker"
30 / Union merges the contents of several remotes
   \ "union"
31 / Webdav
   \ "webdav"
32 / Yandex Disk
   \ "yandex"
33 / http Connection
   \ "http"
34 / premiumize.me
   \ "premiumizeme"
Storage> 22 #选OneDrive
** See help for onedrive backend at: https://rclone.org/onedrive/ **

Microsoft App Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>  #留空
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>  #留空
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n #输入n
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
For this to work, you will need rclone available on a machine that has a web browser available.
Execute the following on your machine (same rclone version recommended) :
    rclone authorize "onedrive"
Then paste the result below:
result> {"access_token":"SSSSSSSSSSSSSSSSSSSSSSSSSSSSS"}  #此处填入刚刚粘贴到记事本的一长串字符
Choose a number from below, or type in an existing value
 1 / OneDrive Personal or Business
   \ "onedrive"
 2 / Root Sharepoint site
   \ "sharepoint"
 3 / Type in driveID
   \ "driveid"
 4 / Type in SiteID
   \ "siteid"
 5 / Search a Sharepoint site
   \ "search"
Your choice> 1 # 输入1
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!1Sg9wBykUUG7wU1GVmWchvoAW_d9Z-FKoQYOkzYZKR5h5aOEEpaMT4XGM99uP_ii
Chose drive to use:> 0 #输入id
Found drive 'root' of type 'business', URL: https://shadoworld-my.sharepoint.com/personal/yushui_gfw_today/Documents
Is that okay?
y) Yes
n) No
y/n> y #输入y
2019/12/24 07:22:38 ERROR : Failed saving config "drive_id" = "b!1Sg9wBykUUG7wU1GVmWSSSSSSSSSSSSSSSSSSSSSSSSEEpaMT4XGM99uP_ii" in section "od1" of the config file: section 'od1' not found
2019/12/24 07:22:38 ERROR : Failed saving config "drive_type" = "business" in section "od1" of the config file: section 'od1' not found
--------------------
[od1]
type = onedrive
token = {"access_token":"SSSSSSSSSSSSSSSSSSSSSSSSSSSS"}
drive_id = b!1Sg9wBykUUG7wU1GVmWcSSSSSSSSSSSSSSSSSSSSSSZKR5h5aOEEpaMT4XGM99uP_ii
drive_type = business
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y #输入y
Current remotes:

Name                 Type
====                 ====
gdrive               drive
od1                  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> q #输入q

挂载为磁盘

mkdir /root/OneDrive #创建用于挂载的路径 即下面的 LocalFolder
rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 #进行挂载,参数解释看下方

DriveName 为初始化配置时随便填写的名称

Folder 为谷歌硬盘里的文件夹路径

LocalFolder 为刚刚创建的目录

示例:

rclone mount od1: /root/OneleDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000

以上这个示例中,Folder为空,表示挂载Google Drive 所有目录文件

挂载可能遇到的问题:

Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH

解决:

# Debian/Ubuntu
apt-get install fuse
# CentOS
yum install fuse

输入 df -h查看挂载的硬盘:

uudme-1577190555.jpg

(水印挡住了……)

开机自启

新建一个rclone1.service文件:

注意:由于我之前已经设置了Google Drive的开机自挂载,所以为了不冲突,配置文件需要修改命名。

GD自启动的配置文件我命名为 rclone.service

OD自启动的配置文件我命名为rclone1.service

vi /usr/lib/systemd/system/rclone1.service

写入:

[Unit]
Description = rclone

[Service]
User = root
ExecStart = /usr/bin/rclone mount od1: /root/OneDrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
Restart = on-abort

[Install]
WantedBy = multi-user.target

重载daemon,让新的服务文件生效:

systemctl daemon-reload

设置开机启动:

systemctl enable rclone1

启动、停止、查看状态可以用:

systemctl start rclone1
systemctl stop rclone1
systemctl status rclone1

完毕

购买Office 365 订阅

  • 本产品适合「只想便捷使用正版Office 办公,不想折腾破解」的朋友
  • 购买后提供一个账号,使用该账号登录 https://www.office.com 进行软件下载安装
  • 账号是一个邮箱及密码,购买前可自定义前缀及密码
  • 可以在 5 台设备上安装软件
  • 包含软件:WordExcelPowerPoint、Outlook、OneNote、Publisher、 Access、Skype for Business、Sharepoint、Onedrive 5TB 网盘、Delve、Video等软件
  • 不推荐使用该账号提供的OneNote、Onedrive存储重要资料
  • 购买链接:https://shop.uud.me/product/
Last modification:March 20, 2020
如果觉得我的文章对你有用,请随意赞赏