rclone魔改版挂载世纪互联OneDrive

共计 10578 个字符,预计需要花费 27 分钟才能阅读完成。

提醒:本文最后更新于2026-09-10 11:26,文中所关联的信息可能已发生改变,请知悉!

rclone魔改版挂载世纪互联OneDrive

官方版rclone不支持挂载世纪互联版本的OneDrive,大佬们修改并编译了支持世纪互联版本的rclone,同时继续支持其他版本的存储方式,记录一下方法。

官方版rclone不支持挂载世纪互联版本的onedrive,大佬们修改并编译了支持世纪互联版本的rclone,同时继续支持其他版本的存储方式,记录一下方法。

1.下载魔改版rclone

windows32位、linux32位、windows64位、linux64位
rclone挂载onedrive需要网页端授权并获取token,即使在远端linux系统上挂载,也需要本地下载Windows rclone来获取授权。

2.注册azure应用

地址:https://portal.azure.cn/,登录完成后按下面步骤进行

左侧Azure Active Directory---应用注册---新注册

名称:自己填写---受支持的账户类型:任何组织目录(任何 Azure AD 目录 - 多租户)中的帐户
---重定向 URI (可选):http://localhost:53682---注册

应用程序(客户端) ID(**复制保存下来,即后面的client_id**)---左侧证书和密码---
右侧客户端密码部分:+新客户端密码

说明:自己填写---截止日期:2年内---添加

客户端密码部分:值(**复制保存下来,即后面的client_secret**)---左侧API权限---
添加权限---Microsoft Graph---委托的权限--- 搜索并勾选下面6个权限:
    Files.Read
    Files.Read.All
    Files.ReadWrite
    Files.ReadWrite.All
    offline_access
    User.Read

到此azure应用就注册完毕了,点击左侧Azure Active Directory—应用注册,可以看到你拥有的应用程序,记住之前应用程序(客户端) ID和客户端密码部分:值

3.挂载世纪互联版onedrive

在这里写下在远端linux主机上如何挂载。

Windows命令行进入rclone所在文件夹,执行命令:

  rclone authorize onedrive "应用程序(客户端) ID" "客户端密码值" --onedrive-is-21vianet-version=true

之后会跳转到浏览器,登录账号之后返回Windows命令行,会返回token,复制保存下来,后面要用。

需要复制的token格式类似于:

{"access_token":"exxxxxxxxxxxxDlkYzQvIiwiaWF0IjoxNTgwOTY5OTA5LCJuYmYiOjE1ODA5Njk5MDksImV4cCI6MTU4MDk3MzgwOSwiY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ubg48AaIjkvVbAhxl-1KnLnocass9Cfbvydlgs4gkVraAhYKEzoxl_meDsJWFtY9iz1ajrRU0l0MzpgUhWT0HgI_cBijmRgwe-mp2oa2h5TFS0UoBOCWQ","token_type":"Bearer","refresh_token":"OAQxxxxxxxxxxxxxxxxxxxxxxxxxxxzOzGoEEJh-Kcl7ktxI56rsY2QB5xKAhZYLfai-Al1CFzyxjdCXlwf5BUTPydTpXnSSoDDOVvs9mn8F8B-otfGJ7U5LJ5xqiRA3NPH5jL1XgGmzMN1CjnJvyPuEOOnS1dSkZu5i8KhgCdEfY8AXLmuq1JLDkAxmJVx_RmXmKidCf_6F9hXRQIelnFnR0X4addzah5Zxb0rrqdQVwNUdltTCsSZBdxo-NXjVbWxxxxxxxxxxxxxxxxxxxxxxxxxIsdC3qBpPBMx30gOMc_us2NVmOr9ybHsS8B-ZUMcVWaLhPtBW9baBKmcYF43-RKJqppZVQmyMaIo2sne72h8k4uUzJdWLPBx8AUlQSrrQaAH_mXMcQ4RG7qKIvfT0oAmrZcf2Fjp_GUPP-02uCd_z-NVZ_yne66jYVgTjqHZq3nuQ2KeTSrPOW9qNKMaCXtCnYj4Fmvr6BkbXR9qvd2SYexDEz7T9bT6T4CbTtBOXF8AY6E52bLkLJHViO3gkqVFtphRFwxaj59rBz466PVDooWxN423iiVhPQAYOQlZujea_R-tWmKjME8-4RVKaSZY0cW2ojaMRMT00RcWCCJ7PBedPYoVDDZ8Bn6W4VT8Phma0yS-cvy3EIjfI-p3Ojy4mLruaWagFlTfgqgq1it8whfpu6xPys1NGYBHm9fW6E4bU8YtzGXxzKmJ62INvYizoNbEfxBtjMx8etuze2qj5EJkPTfsbgzD6IbB_fQDxaYPGFM_3_zHOwkPUirkigWjWnpdNzqdRbiYxO06FsYkgAA","expiry":"2020-02-06T15:23:28.6393091+08:00"}

然后用ssh

接下来将linux版的解压上传到usr/bin目录(必须此目录),然后给权限chmod +x /usr/bin/rclone
执行rclone config,就进入了和官方版rclone一样的挂载程序,和国际版onedrive不同的是:client_id填写应用程序(客户端) ID,client_secret填写客户端密码。is_21vianet_version填true,Edit advanced config以及Use auto config都选no,下一步粘贴上之前在Windows获取的token,继续按提示完成之后的步骤。

上面绑定了账号之后将网盘挂载到linux主机。先安装fuse命令:

yum install fuse

创建挂载文件夹:

mkdir -p /mnt/od(替换自己的目录)

挂载:

rclone mount od(在绑定账号时起的名字): /mnt/od(挂载目录) --allow-other --allow-non-empty --vfs-cache- 
mode writes&

这样就挂载成功了,可以输入df -h查看。
重启主机挂载就会失效,网上也有添加自动挂载的教程。

完整高级配置过程如下:

完整配置过程如下

>rclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n             #新建一个
name> onedrive_cn    #配置名称,随便填
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                    #新建 Microsoft 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> 6b57cb03-3791-4823-9ce9-5dd027e*****        #应用程序(客户端) client_id** ID
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> l05:IBoAAVh4]Y]4M_?9lgw-L8******       #密码 client_secret**
OneDrive operated by 21Vianet (世纪互联).
Enter a boolean value (true or false). Press Enter for the default ("false").
is_21vianet_version> true
Edit advanced config? (y/n)
y) Yes
n) No
y/n> y
Chunk size to upload files with - must be multiple of 320k (327,680 bytes).

Above this size files will be chunked - must be multiple of 320k (327,680 bytes). Note
that the chunks will be buffered into memory.
Enter a size with suffix k,M,G,T. Press Enter for the default ("10M").
chunk_size> 10M
The ID of the drive to use
Enter a string value. Press Enter for the default ("").
drive_id>
The type of the drive ( personal | business | documentLibrary )
Enter a string value. Press Enter for the default ("").
drive_type> business
Set to make OneNote files show up in directory listings.

By default rclone will hide OneNote files in directory listings because
operations like "Open" and "Update" won't work on them.  But this
behaviour may also prevent you from deleting them.  If you want to
delete OneNote files or otherwise want them to show up in directory
listing, set this option.
Enter a boolean value (true or false). Press Enter for the default ("false").
expose_onenote_files>
Remote config
Make sure your Redirect URL is set to "http://localhost:53682/" in your custom 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> Y
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=3-n1fmI2XA7QsjnhQAjoQw
Log in and authorize rclone for access
Waiting for code...
Got code
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
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!Yb3jWYP2_EOgiOjYxlsv4iz1Y8ZSfhlEm48kp98Ew0Dzv4TUrSwSSK1sL5j*****
Chose drive to use:> 0
Found drive 'root' of type 'business', URL: https://*****-my.sharepoint.cn/personal/***_****_partner_onmschina_cn/Documents
Is that okay?
y) Yes
n) No
y/n> y
--------------------
[onedrive_cn]
type = onedrive
client_id = 6b57cb03-3791-4823-9ce9-5dd027e*****
client_secret = l05:IBoAAVh4]Y]4M_?9lgw-L8******
is_21vianet_version = true
chunk_size = 10M
drive_type = business
token = {"access_token":"eyJ0eXAiOiJKV1Q********BtBs2OM8B1Euv7SAA","expiry":"2020-02-01T14:50:32.8151941+08:00"}
drive_id = b!Yb3jWYP2_EOgiOjYxlsv4iz1Y8****************UrSwSSK1sL5jmrG0I
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:

Name                 Type
====                 ====
onedrive_cn        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

配置文件C:\Users\user\.config\rclone\rclone.conf格式如下

[onedrive_cn]
type = onedrive
client_id = 6b57cb03-3791-4823-9ce9-5dd027e*****
client_secret = l05:IBoAAVh4]Y]4M_?9lgw-L8******
is_21vianet_version = true
chunk_size = 10M
drive_type = business
token = {"access_token":"eyJ0eXAiOiJKV1Q********BtBs2OM8B1Euv7SAA","expiry":"2020-02-01T14:50:32.8151941+08:00"}
drive_id = b!Yb3jWYP2_EOgiOjYxlsv4iz1Y8****************UrSwSSK1sL5jmrG0I

挂载

apt -y update && apt install fuse

挂载命令:

rclone mount onedrive:/ /mnt/ --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000

后台挂载命令:

nohup rclone mount onedrive:/ /mnt --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 >/dev/null 2>&1 &

卸载命令:

fusermount -qzu LocalFolder onedrive

Rclone 开机启动(脚本来自:Rat’s Blog,二次修改支持多网盘挂载)

nano /etc/init.d/rcloned

文本内容如下

#!/bin/bash

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
NAME_BIN="rclone"
### BEGIN INIT INFO
# Provides:          rclone
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start rclone at boot time
# Description:       Enable rclone by daemon.
### END INIT INFO

NAME="" #rclone name名
REMOTE='' #远程文件夹
LOCAL='' #挂在地址

NAME_1=""
REMOTE_1=''
LOCAL_1=''

Green_font_prefix="\033[32m" && Red_font_prefix="\033[31m" && Green_background_prefix="\033[42;37m" && Red_background_prefix="\033[41;37m" && Font_color_suffix="\033[0m"
Info="${Green_font_prefix}[信息]${Font_color_suffix}"
Error="${Red_font_prefix}[错误]${Font_color_suffix}"
RETVAL=0

check_running(){
    PID="$(ps -C $NAME_BIN -o pid= |head -n1 |grep -o '[0-9]\{1,\}')"
    if [[ ! -z ${PID} ]]; then
        return 0
    else
        return 1
    fi
}
do_start(){
    check_running
    if [[ $? -eq 0 ]]; then
        echo -e "${Info} $NAME_BIN (PID ${PID}) 正在运行..." && exit 0
    else
        fusermount -zuq $LOCAL >/dev/null 2>&1
        mkdir -p $LOCAL
        /usr/bin/rclone mount $NAME:$REMOTE $LOCAL --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 >/dev/null 2>&1 &
        sleep 2s
        fusermount -zuq $LOCAL_1 >/dev/null 2>&1
        mkdir -p $LOCAL_1
        /usr/bin/rclone mount $NAME_1:$REMOTE_1 $LOCAL_1 --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 >/dev/null 2>&1 &
        check_running
        if [[ $? -eq 0 ]]; then
            echo -e "${Info} $NAME_BIN 启动成功 !"
        else
            echo -e "${Error} $NAME_BIN 启动失败 !"
        fi
    fi
}
do_stop(){
    check_running
    if [[ $? -eq 0 ]]; then
        kill -9 ${PID}
        RETVAL=$?
        if [[ $RETVAL -eq 0 ]]; then
            echo -e "${Info} $NAME_BIN 停止成功 !"
        else
            echo -e "${Error} $NAME_BIN 停止失败 !"
        fi
    else
        echo -e "${Info} $NAME_BIN 未运行"
        RETVAL=1
    fi
    fusermount -zuq $LOCAL >/dev/null 2>&1
    fusermount -zuq $LOCAL1 >/dev/null 2>&1
}
do_status(){
    check_running
    if [[ $? -eq 0 ]]; then
        echo -e "${Info} $NAME_BIN (PID $(echo ${PID})) 正在运行..."
    else
        echo -e "${Info} $NAME_BIN 未运行 !"
        RETVAL=1
    fi
}
do_restart(){
    do_stop
    do_start
}
case "$1" in
    start|stop|restart|status)
    do_$1
    ;;
    *)
    echo "使用方法: $0 { start | stop | restart | status }"
    RETVAL=1
    ;;
esac
exit $RETVAL

操作命令

chmod +x /etc/init.d/rcloned
/etc/init.d/rcloned start
/etc/init.d/rcloned stop

正文完
 0