非凡居

linux VPS挂载OneDrive网盘来做本地磁盘

1、windows下载rclone-v1.51.0软件
https://rclone.org/downloads/。然后解压出来,比如我解压到D盘,文件夹命名rclone,此时点击Win+R,然后输入cmd,确定。再输入以下命令:

2、获取token

  1. 开始运行——CMD回车
  2. d:
  3. cd rclone
  4. rclone.exe authorize "onedrive"

弹出登录对话框,登录自己的OneDrive
登录成功后会获取到一串Token,保存备用
{“access_token”:————————-472605+08:00″}包括大括号都要复制

linux下载安装rclone(注意保持和windows软件版本保持一致,否则会报错)
本教程只适用Debian/Ubuntu系统,如果你是CentOS,请参考:https://rclone.org/install/,安装rclone。挂载方法和下面差不多。

3、linux安装rclone

  1. wget https://www.moerats.com/usr/shell/rclone_debian.sh && bash rclone_debian.sh

4、执行rclone config配置

  1. root@ubuntu-tw:~# rclone config
  2. Current remotes:
  3. Name Type
  4. ==== ====
  5. onedrive-Z4050 onedrive
  6. e) Edit existing remote
  7. n) New remote
  8. d) Delete remote
  9. r) Rename remote
  10. c) Copy remote
  11. s) Set configuration password
  12. q) Quit config
  13. e/n/d/r/c/s/q> n
  14. name> onedrive
  15. Type of storage to configure.
  16. Enter a string value. Press Enter for the default ("").
  17. Choose a number from below, or type in your own value
  18. 1 / 1Fichier
  19. \ "fichier"
  20. 2 / Alias for an existing remote
  21. \ "alias"
  22. 3 / Amazon Drive
  23. \ "amazon cloud drive"
  24. 4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
  25. \ "s3"
  26. 5 / Backblaze B2
  27. \ "b2"
  28. 6 / Box
  29. \ "box"
  30. 7 / Cache a remote
  31. \ "cache"
  32. 8 / Citrix Sharefile
  33. \ "sharefile"
  34. 9 / Dropbox
  35. \ "dropbox"
  36. 10 / Encrypt/Decrypt a remote
  37. \ "crypt"
  38. 11 / FTP Connection
  39. \ "ftp"
  40. 12 / Google Cloud Storage (this is not Google Drive)
  41. \ "google cloud storage"
  42. 13 / Google Drive
  43. \ "drive"
  44. 14 / Google Photos
  45. \ "google photos"
  46. 15 / Hubic
  47. \ "hubic"
  48. 16 / In memory object storage system.
  49. \ "memory"
  50. 17 / JottaCloud
  51. \ "jottacloud"
  52. 18 / Koofr
  53. \ "koofr"
  54. 19 / Local Disk
  55. \ "local"
  56. 20 / Mail.ru Cloud
  57. \ "mailru"
  58. 21 / Mega
  59. \ "mega"
  60. 22 / Microsoft Azure Blob Storage
  61. \ "azureblob"
  62. 23 / Microsoft OneDrive
  63. \ "onedrive"
  64. 24 / OpenDrive
  65. \ "opendrive"
  66. 25 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
  67. \ "swift"
  68. 26 / Pcloud
  69. \ "pcloud"
  70. 27 / Put.io
  71. \ "putio"
  72. 28 / QingCloud Object Storage
  73. \ "qingstor"
  74. 29 / SSH/SFTP Connection
  75. \ "sftp"
  76. 30 / Sugarsync
  77. \ "sugarsync"
  78. 31 / Transparently chunk/split large files
  79. \ "chunker"
  80. 32 / Union merges the contents of several remotes
  81. \ "union"
  82. 33 / Webdav
  83. \ "webdav"
  84. 34 / Yandex Disk
  85. \ "yandex"
  86. 35 / http Connection
  87. \ "http"
  88. 36 / premiumize.me
  89. \ "premiumizeme"
  90. Storage> 23
  91. ** See help for onedrive backend at: https://rclone.org/onedrive/ **
  92. Microsoft App Client Id
  93. Leave blank normally.
  94. Enter a string value. Press Enter for the default ("").
  95. client_id>
  96. Microsoft App Client Secret
  97. Leave blank normally.
  98. Enter a string value. Press Enter for the default ("").
  99. client_secret>
  100. Edit advanced config? (y/n)
  101. y) Yes
  102. n) No (default)
  103. y/n> n
  104. Remote config
  105. Use auto config?
  106. Say Y if not sure
  107. Say N if you are working on a remote or headless machine
  108. y) Yes (default)
  109. n) No
  110. y/n> n
  111. For this to work, you will need rclone available on a machine that has a web browser available.
  112. Execute the following on your machine (same rclone version recommended) :
  113. rclone authorize "onedrive"
  114. Then paste the result below:
  115. result> {"access_token":"eyJ0eXAiOiJKV1QiLCJub25jZSI6IjBqMWx5S0NRdVlMQVJKazh0bHRQYlJCR5vuyKckP6SeyKnWylwQ9gjgDb0f7M520HhavwyFCFv8VrjThZANxwICVL0KHY9vGq67dt5_X7tgbS-c8aLnC5WpOyfjFk99oZk0rcFglDGw5VuKqBHhX5Itbqz-IMgAA","expiry":"2020-03-23T09:47:50.472605+08:00"}
  116. Choose a number from below, or type in an existing value
  117. 1 / OneDrive Personal or Business
  118. \ "onedrive"
  119. 2 / Root Sharepoint site
  120. \ "sharepoint"
  121. 3 / Type in driveID
  122. \ "driveid"
  123. 4 / Type in SiteID
  124. \ "siteid"
  125. 5 / Search a Sharepoint site
  126. \ "search"
  127. Your choice> 1
  128. Found 1 drives, please select the one you want to use:
  129. 0: OneDrive (business) id=b!pqedh1cM1ku141LKYzPiZDag1hP5EPNGuhgzFq97e8D9kzUXM2-YQ5xBdH_Nhhx0
  130. Chose drive to use:> 0
  131. Found drive 'root' of type 'business', URL: https://uijay-my.sharepoint.com/personal/wxj_myoffice_fun/Documents
  132. Is that okay?
  133. y) Yes (default)
  134. n) No
  135. y/n> y
  136. [onedrive]
  137. type = onedrive
  138. token = {"access_token":"eyJ0eXAiOiJKV1QiLCJub25jZSI6IjBqMWx5S0NRdVlMQVJKazh0bHRQYlJ7dt5_X7tgbS-c8aLnC5WpOyfjFk99oZk0rcFglDGw5VuKqBHhX5Itbqz-IMgAA","expiry":"2020-03-23T09:47:50.472605+08:00"}
  139. drive_id = b!pqedh1cM1ku141LKYzPiZDag1hP5EPNGuhgzFq97e8D9kzUXM2-YQ5xBdH_Nhhx0
  140. drive_type = business
  141. y) Yes this is OK (default)
  142. e) Edit this remote
  143. d) Delete this remote
  144. y/e/d> y
  145. Current remotes:
  146. Name Type
  147. ==== ====
  148. onedrive onedrive
  149. e) Edit existing remote
  150. n) New remote
  151. d) Delete remote
  152. r) Rename remote
  153. c) Copy remote
  154. s) Set configuration password
  155. q) Quit config
  156. e/n/d/r/c/s/q>q

5、挂载onedrive(运行命令的时候会卡住,重新再打开一个窗口即可)

  1. rclone mount onedrive:/ /www/onedrive --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --daemondaemon
  2. #daemon后台模式

6、查看挂载是否成功

  1. df-h