win10下使用Rclone將OneDrive映射到本地磁盤教程(開機自動掛載)
onedrive雲盤是微軟推出的雲儲存空間服務,相比於百度雲,沒有會員限制,有着較快的下載上傳速度。採用Rclone軟件可將onedrive映射爲電腦本地,成爲電腦上的一個(雲)磁盤空間,便於使用,且Rclone支持全平臺,能夠在不同操作系統上對onedrive進行掛載。
本文主要介紹win10下使用Rclone將OneDrive映射到本地磁盤,並且實現了win10系統開機自動掛載,有效解決了電腦重啓後onedrive掛載盤丟失需要重新手動掛載的問題。
最終得到的效果如圖所示(5T onedrive磁盤)
下載rclone,winfsp和Git bash
首先需要下載和安裝掛載所需的軟件和輔助工具。
一共有3個:
Rclone:https://github.com/rclone/rclone/releases
Winfsp:https://github.com/billziss-gh/winfsp/releases
Git bash:https://gitforwindows.org/
Rclone.
點擊鏈接進入下載網址,可以看到有許多不同的版本,適用於Windows系統有rclone-v1.51.0-windows-amd64.zip和rclone-v1.51.0-windows-386.zip,根據自己電腦是64位的還是32位的對應選擇合適的壓縮包下載。
我的電腦是64位的系統,所以下載紅框圈出的壓縮包,rclone-v1.51.0-windows-amd64.zip
。
下載完成之後,將壓縮包解壓到一個全英文的目錄下,例如我解壓到了D:\Program Files\rclone-v1.51.0-windows-amd64
Winfsp. 和 Git bash.
下載之後直接安裝即可,無需修改安裝位置,一路按默認的點下去就可。
考慮到github網站下載速度較慢,我將上述Rclone和Winfsp的安裝文件下載好之後,放在網盤裏分享出來供大家使用。
鏈接:https://pan.baidu.com/s/1g3OxTiuIr2b86w2-zq5liA
提取碼:hksx
配置Rclone
安裝好這幾個軟件後,開始配置Rclone。
- 首先修改windows系統的環境變量,將rclone的路徑添加到path中:
在桌面上右鍵點擊此電腦標誌,然後點擊屬性->高級系統設置->環境變量->系統變量->Path
添加rclone文件夾的路徑到path中,我電腦上rclone放置的路徑在D:\Program Files\rclone-v1.51.0-windows-amd64
2. 修改好環境變量之後,打開windows powershell,配置rclone.config。
按鍵盤上的win+x,然後按a鍵,即可調出windows powershell
輸入rclone --version,可查看rclone是否成功安裝。
Windows PowerShell
版權所有 (C) Microsoft Corporation。保留所有權利。
嘗試新的跨平臺 PowerShell https://aka.ms/pscore6
PS C:\Windows\system32> rclone --version
rclone v1.51.0
- os/arch: windows/amd64
- go version: go1.13.7
查看成功安裝rclone後,輸入rclone config,配置要加載的onedrive信息,按照下面的步驟依次進行下去。
PS C:\Windows\system32> rclone config (步驟1. 輸入rclone config)
2020/04/25 13:29:37 NOTICE: Config file "C:\\Users\\dell\\.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/s/q> n (步驟2. 輸入n,表示新建配置)
name> onedrive (步驟3. 命名爲"onedrive",也可取其他的名字,但要與下面所使用的名字保持一致)
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
Storage> 23 (步驟4. 輸入數字23,因爲Microsoft OneDrive對應的類型是23)
** 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> (步驟5. 按enter鍵跳過)
Microsoft App Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret> (步驟6. 按enter鍵跳過)
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n (步驟7. 輸入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
y/n> y (步驟8. 輸入y,採用默認設置)
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=lcvcDmCLf1ugmaCzlEtMSA
Log in and authorize rclone for access
Waiting for code...
----------------------------------
(步驟8執行後會跳轉到Microsoft OneDrive賬號登錄界面和授權界面,登錄後在授權請求界面點擊“是”)
-----------------------------------
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 (步驟9. 輸入1,數字1對應OneDrive Personal or Business)
Found 1 drives, please select the one you want to use:
0: (personal) id=cdffcd6a2a3dc176
Chose drive to use:> 0 (步驟10. 輸入0,數字0對應OneDrive個人版)
Found drive 'root' of type 'personal', URL: https://onedrive.live.com/?cid=cdffcd6a2a3dc176
Is that okay?
y) Yes (default)
n) No
y/n> y 0 (步驟11. 輸入y,採用默認設置)
--------------------
[onedrive]
type = onedrive
token = {"access_token":"(隱私信息省略)*************************************************************************************
drive_id = (隱私信息省略)***************
drive_type = personal
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y (步驟12. 輸入y)
Current remotes:
Name Type
==== ====
onedrive 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 (步驟13. 輸入q,退出)
完成rclone配置後,掛載onedrive磁盤。
在git中輸入如下命令並執行(注意,末尾的&很重要,不加&的話退出git則掛載就失效了):
rclone mount onedrive:/ E: --cache-dir D:\Onedrive --vfs-cache-mode writes &
到這一步,就可以在電腦上看到多出一個onedrive(E)磁盤。
但還沒有結束,還需要解決電腦重啓後掛載失效的問題。
開機自動掛載
採用開機自動掛載的方式,可有效解決電腦重啓後onedrive磁盤消息的問題,省去重新手動掛載的麻煩。
新建兩個文件,分別爲rclone.bat和rclone.vbs
- rclone.bat中寫入上述掛載命令:
rclone mount onedrive:/ E: --cache-dir D:\Onedrive --vfs-cache-mode writes &
- rclone.vbs設置開機自動調用cmd運行rclone.bat文件並退出cmd,寫入如下代碼:
CreateObject("WScript.Shell").Run "cmd /c D:/rclone.bat",0
將rclone.bat文件放到D盤(或其他的盤)目錄下,我放在了D盤,所以在rclone.vbs中該文件的路徑就是D:/rclone.bat
將rclone.vbs文件放到windows系統啓動項目錄下,在文件夾的路徑框中輸入
%USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
即可進入啓動項目錄
至此,onedrive磁盤的掛載完成,且電腦下次開機時onedrive磁盤也不會消失