欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

centos 挂载 onedirve

程序员文章站 2024-03-15 23:22:24
...


挂载onedrive需要浏览器登录授权,而centos一般作为服务器使用,额米有界面,需要先在windows上使用rclone获取授权**,然后在centos上完成挂载。

获取授权**

  1. 下载rclone window版本

    rclone download下载对应的win版本rclone
    centos 挂载 onedirve

  2. 下载后解压,并从命令行运行rclone authorize "onedrive"

  3. 在自动打开的浏览器中登录,登录后会跳转到授权成功的页面。授权成功后回到CMD窗口,会看到如下:
    centos 挂载 onedirve

  4. 把{}括号里面的内容复制下来保存好,后面需要用到(包含括号一起复制保存

centos挂载onedrive

软件安装

  1. 安装rclone
curl https://rclone.org/install.sh | sudo bash
  1. 安装fuse
yum install fuse

rclone配置

  1. 启动配置

    rclone config
    
  2. 创建一个新配置

    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 # 输入n 创建一个新的配
    
  3. 自定义配置名称

    name> onedrive-chuqidecha # 这里自己输入名字
    
  4. 选择需要挂载的网盘

    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 / In memory object storage system.
       \ "memory"
    17 / JottaCloud
       \ "jottacloud"
    18 / Koofr
       \ "koofr"
    19 / Local Disk
       \ "local"
    20 / Mail.ru Cloud
       \ "mailru"
    21 / Mega
       \ "mega"
    22 / Microsoft Azure Blob Storage
       \ "azureblob"
    23 / Microsoft OneDrive
       \ "onedrive"
    24 / OpenDrive
       \ "opendrive"
    25 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
       \ "swift"
    26 / Pcloud
       \ "pcloud"
    27 / Put.io
       \ "putio"
    28 / QingCloud Object Storage
       \ "qingstor"
    29 / SSH/SFTP Connection
       \ "sftp"
    30 / Sugarsync
       \ "sugarsync"
    31 / Transparently chunk/split large files
       \ "chunker"
    32 / Union merges the contents of several remotes
       \ "union"
    33 / Webdav
       \ "webdav"
    34 / Yandex Disk
       \ "yandex"
    35 / http Connection
       \ "http"
    36 / premiumize.me
       \ "premiumizeme"
    Storage> 23 #这里onedrive是23,不同的rclone版本数字可能不同
    
  5. client_id和client_scret不用管,直接留空

    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> # 什么都不用输入,直接回车
    
  6. 不使用高级配置

    Edit advanced config? (y/n)
    y) Yes
    n) No (default)
    y/n> n # 不使用,输入n
    
  7. 不使用远程配置

    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
    y/n> n # 不使用,输入n
    
  8. 输入授权**

    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> # 这里输入windows下获取的**
    
  9. 选择类型为onedrive

    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 # 选择onedrive
    
  10. 选择驱动

    Found 1 drives, please select the one you want to use:
    0:  (personal) id=7e574746be4c2c00
    Chose drive to use:> 0 # 这里只有个人版,输入0
    
  11. 确认并退出配置

    Found drive 'root' of type 'personal', URL: https://onedrive.live.com/?cid=7e574746be4c2c00
    Is that okay?
    y) Yes (default)
    n) No
    y/n> y # 确认选择
    
    --------------------
    [onedrive-chuqidecha]
    type = onedrive
    token = {"access_token":"这里是**,省略"}
    drive_id = 7e574746be4c2c00
    drive_type = personal
    --------------------
    y) Yes this is OK (default)
    e) Edit this remote
    d) Delete this remote
    y/e/d> y # 如果配置没问题,继续确认
    Current remotes:
    
    Name                 Type
    ====                 ====
    onedrive-chuqidecha  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 # 退出配置
    

挂载

  1. 创建挂载目录

    mkdir -p /netdisk/onedrive-chuqidecha
    
  2. 后台挂载

    nohup rclone mount DriveName:Folder LocalFolder --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 > logs/log.log 2>&1 &
    
    • DriveName为初始化配置填的`name``
    • ``FolderOneDrive`里的文件夹
    • LocalFolder为本地挂载的目标目录
  3. 检查是否挂载成功

df -h

centos 挂载 onedirve

卸载

fusermount -qzu LocalFolder
相关标签: 小工具 onedrive