
教你如何把Onedrive映射到本地磁盘中!
前言
把Onedrive映射到本地磁盘是为了节省空间,因为Onedrive自带的同步功能太烂了,看个视频都要等下好了才可以看(磁盘占用太大),根本不能在线看(在线看只要缓存没看的部分,看了的部分会自动删除,超节省磁盘空间)。只要用了我这种方法,把Onedrive映射到本地磁盘上,就可以大大减少磁盘占用了!
正文
获取Refresh_Token
首先需要下载rclone(如果下载速度慢可以试试这个链接,里面有很多文件,但你只需要下载适合你系统的就可以了。文件格式是“rclone-版本号-你的系统-架构”,其中,32位是386,64位是amd64,比如64位Windows就是rclone-版本号-windows-amd64)
然后把里面的文件解压到你喜欢的地方,比如我就是解压在桌面上。
然后打开解压出来的rclone文件夹。
然后在文件夹内打开cmd(按住Shift和右键,选择在此打开命令窗口),Linux是终端,然后输入
rclone authorize "onedrive"
这一步是为了获取MS的Refresh_Token。然后在弹出来的浏览器窗口中选择账户(这个账户的Onedrive将会被映射到本地磁盘当中)然后我们要代表组织同意,然后点”接受”(企业版和教育版才有这个为问题)
个人版会显示“讓此應用程式存取您的資訊嗎?”,这时我们点”是”即可
然后出现“Success!”之后返回cmd,复制如图高亮(也就是{“access_token”: 一直到”}”的一段)的这一段即可
新建配置
输入 rclone config
然后输入n
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
然后在 name>
的内容随便填,后面要作为config_name(即配置名)使用。
然后在 Storage
后面输入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 Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, SeaweedFS, 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 / Uptobox \ "uptobox" 38 / Webdav \ "webdav" 39 / Yandex Disk \ "yandex" 40 / Zoho \ "zoho" 41 / http Connection \ "http" 42 / premiumize.me \ "premiumizeme" 43 / seafile \ "seafile" Storage>onedrive #输入onedrive
然后Client_id我们用默认的就可以了,即按Enter键
OAuth Client Id Leave blank normally. Enter a string value. Press Enter for the default (""). client_id> #按Enter键继续
然后Client_secret我们也是用默认的,即也是按Enter键
OAuth Client Secret Leave blank normally. Enter a string value. Press Enter for the default (""). client_secret> #按Enter键继续
然后region,国际版填global,中国世纪互联用户填cn
Choose national cloud region for OneDrive. Enter a string value. Press Enter for the default ("global"). Choose a number from below, or type in your own value 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" region> #国际版填global,中国世纪互联填cn
然后在 y/n
后面输入n或按Enter键
Edit advanced config? y) Yes n) No (default) y/n>n #输入n或按Enter键
然后我们输入y或按Enter键
`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 输入y或按Enter键`然后他可能会让你再次登录MS账户,这时登录即可
然后我们在
config_type>
后面输入onedrive1 / 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" config_type>onedrive #输入onedrive
然后我们在
y/n>
后面输入或者按Enter键`Drive OK?
Found drive “root” of type “business”
URL: https://xxx-my.sharepoint.com/personal/xxx_xxx_onmicrosoft_com/Documentsy) Yes (default)
n) No
y/n>y #输入y或按Enter键`然后我们在
y/e/d>
后面输入y`[example]
type = onedrive
token = {“access_token”:”xxxxx”}
drive_id = xxxxdrive_type = business
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d>y 输入y`然后我们输入q退出rclone
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 #输入q退出rclone
然后我们输入以下命令来挂载Onedrive
Windows用户
rclone mount config_name: drive_letter: --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --vfs-cache-mode writes
config_name就是你一开始输入的配置名,drive_letter就是要挂载在哪个盘,不要输入现在已有的盘,比如C盘,D盘
Linux用户:
rclone mount DriveName: LocalFolder --umask 0000 --default-permissions --allow-non-empty --allow-other --transfers 1 --buffer-size 64M --low-level-retries 200 &
DriveName就是你一开始输入的配置名,LocalFolder就是你想挂载到哪个本地文件夹内(要有绝对路径!!)
Windows设置开机自启,cmd后台运行
首先我们按Windows微标键(即位于X键下面,Fn和左Alt之间的按键)+R键调出运行窗口,然后输入%appdata%\Microsoft\Windows\Start Menu\Programs\Startup
进入启动文件夹
然后在这里面新建一个.txt文件然后在里面输入
if "%1"=="hide" goto CmdBegin start mshta vbscript:createobject("wscript.shell").run("""%~0"" hide",0)(window.close)&&exit :CmdBegin cd "rcloneFolder" rclone mount config_name: Drive_letter: --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --vfs-cache-mode writes
rcloneFolder
是指Rclone所在的文件夹,要完整,例如C:/example/rclone 。config_name
就是你一开始输入的配置名,Drive_letter
就是你想挂载到哪个盘,不要输入现在已有的盘,比如C盘,D盘,然后保存。最后把.txt重命名为.bat(记得打开显示文件扩展名!!!!!!)