安装

yum

yum install rclone

脚本

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

初始化配置

rclone config
2022/05/29 17:08:32 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaults
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
  • 输入 n​ 新建配置
  • 输出name​ (随意)

    name> oneDriver
    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 Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, and Tencent COS
       \ "s3"
     5 / Backblaze B2
       \ "b2"
     6 / Box
       \ "box"
     7 / Cache a remote
       \ "cache"
     8 / Citrix Sharefile
       \ "sharefile"
     9 / Compress a remote
       \ "compress"
    10 / Dropbox
       \ "dropbox"
    11 / Encrypt/Decrypt a remote
       \ "crypt"
    12 / Enterprise File Fabric
       \ "filefabric"
    13 / FTP Connection
       \ "ftp"
    14 / Google Cloud Storage (this is not Google Drive)
       \ "google cloud storage"
    15 / Google Drive
       \ "drive"
    16 / Google Photos
       \ "google photos"
    17 / Hadoop distributed file system
       \ "hdfs"
    18 / Hubic
       \ "hubic"
    19 / In memory object storage system.
       \ "memory"
    20 / Jottacloud
       \ "jottacloud"
    21 / Koofr
       \ "koofr"
    22 / Local Disk
       \ "local"
    23 / Mail.ru Cloud
       \ "mailru"
    24 / Mega
       \ "mega"
    25 / Microsoft Azure Blob Storage
       \ "azureblob"
    26 / Microsoft OneDrive
       \ "onedrive"
    27 / OpenDrive
       \ "opendrive"
    28 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
       \ "swift"
    29 / Pcloud
       \ "pcloud"
    30 / Put.io
       \ "putio"
    31 / QingCloud Object Storage
       \ "qingstor"
    32 / SSH/SFTP Connection
       \ "sftp"
    33 / Sugarsync
       \ "sugarsync"
    34 / Tardigrade Decentralized Cloud Storage
       \ "tardigrade"
    35 / Transparently chunk/split large files
       \ "chunker"
    36 / Union merges the contents of several upstream fs
       \ "union"
    37 / Webdav
       \ "webdav"
    38 / Yandex Disk
       \ "yandex"
    39 / Zoho
       \ "zoho"
    40 / http Connection
       \ "http"
    41 / premiumize.me
       \ "premiumizeme"
    42 / seafile
       \ "seafile"
  • 选择 onedrive​ 26​
  • ​client_id​ 可以直接回车默认,
    ​client_secret​ 也可以直接回车默认,

    1 / Microsoft Cloud Global
       \ "global"
     2 / Microsoft Cloud for US Government
       \ "us"
     3 / Microsoft Cloud Germany
       \ "de"
     4 / Azure and Office 365 operated by 21Vianet in China
       \ "cn"

    选择 1​

  • 进阶配置选择,如下:

    Edit advanced config? (y/n)
    y) Yes
    n) No (default)
    y/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 (default)
    n) No

    选择 n​

  • 获取授权码

    For this to work, you will need rclone available on a machine that has
    a web browser available.
    
    For more help and alternate methods see: https://rclone.org/remote_setup/
    
    Execute the following on the machine with the web browser (same rclone
    version recommended):
    
            rclone authorize "onedrive"
    
    Then paste the result below:

    授权码需要在本地电脑上获取,访问 https://rclone.org/downloads/ 根据你的电脑系统版本下载对应的 Rclone。

    1. 进入下载的文件夹里,在cmd​里执行以下命令

      rclone authorize "onedrive"
    2. 在弹出的网页中登录并授权,出现 success!​ 则代表授权成功
    3. 将 cmd​ 里的 json​ 串(授权信息)复制战列到linux终端
  • 选择授权的类型

    Choose a number from below, or type in an existing value
     1 / OneDrive Personal or Business
       \ "onedrive"
     2 / Root Sharepoint site
       \ "sharepoint"
     3 / Sharepoint site name or URL (e.g. mysite or https://contoso.sharepoint.com/sites/mysite)
       \ "url"
     4 / Search for a Sharepoint site
       \ "search"
     5 / Type in driveID (advanced)
       \ "driveid"
     6 / Type in SiteID (advanced)
       \ "siteid"
     7 / Sharepoint server-relative path (advanced, e.g. /teams/hr)
       \ "path"

    这里选择 1​ OneDrive Personal or Business

    然后根据提示输入序号

    Your choice> 1
    Found 1 drives, please select the one you want to use:
    0:  (personal) id=e93acbe1b98f1996

    输入0​ 选择

    Chose drive to use:> 0
    Found drive 'root' of type 'personal', URL: https://onedrive.live.com/?cid=xxxxxxxxxxxx
    Is that okay?
    y) Yes (default)
    n) No
    y/n>

    这里根据序号查找到账号,确认后输入y​

    再次输入 y​ 确认配置

挂载

挂载命令

# 格式
rclone mount configName:OneDriveLocation dir --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000

其中 configName​ 为配置名称,OneDriveLocation​ 是要挂载的 OneDrive​目录 ,dir​ 是本地要挂载的目录(服务器目录)。

例如将刚刚配置的 name​ 为 onedriver​ 的 文档/SiYuan-workspace/SiYuan​目录配置挂载到本地的 onedrive​ 目录下,则命令为:

rclone mount onedrive:/文档/siYuan/mc/data /data/siyuan/mc/data --copy-links  --no-check-certificate --allow-other --allow-non-empty --umask 000 --vfs-cache-mode full

挂载完后不会显示任何内容,通过命令查看挂载情况

df -h

常见挂载错误提示

  • 2022/05/29 17:52:14 NOTICE: One drive root '文档/SiYuan-workspace/SiYuan': --vfs-cache-mode writes or full is recommended for this remote as it can't stream
    2022/05/29 17:52:14 Fatal error: failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH

    需要安装 fuse

    1. CentOS/Fedora 安装 fuse
      yum install -y fuse​
    2. Ubuntu/Debian 安装 fuse
      apt install -y fuse​
    3. 重新执行挂载命令
  • 2022/05/29 17:54:38 NOTICE: One drive root '文档/SiYuan-workspace/SiYuan': --vfs-cache-mode writes or full is recommended for this remote as it can't stream
    2022/05/29 17:54:39 Fatal error: failed to mount FUSE fs: mountpoint does not exist: /data/onedrive

    创建本地服务器文件

    cd /data
    mkdir onedrive
如果觉得我的文章对你有用,请随意赞赏