開開心心買的雲服務器準備部署自己的博客,什麼?只有20GB存儲空間???,what fk?? 拉一拉存儲升配的進度條,什麼?what fk? 竟然可以這麼貴? 太不適合我們這些羊毛黨的風格了!! 那怎麼辦呢?
在linux服務器上掛載OneDrive獲取免費TB級存儲空間
Centos7.x操作系統;
Microsoft 365 E3 A1P EDU郵箱等賬號;
rclone掛載工具;
流程
我們在Windows環境下使用rclone獲取Microsoft OneDrive的token,然後在Linux服務器中使用rclone創建一個該token對應的存儲,然後將該存儲掛載在服務器的目錄中,配置好開機啟動,完成。
1.獲取token
rclone一是款支持多種環境掛載存儲的工具,支持掛載Microsoft OneDrive,Amazon Cloud Drive,Dropbox,FTP Connection,SSH/SFTP Connection等多種方式。
在本地Windows下使用rclone獲取Microsoft賬號對應的token,rclone下載地址為https://rclone.org/downloads/
解壓下載包,進入解壓後目錄
在藍色處刪除所有內容,輸入cmd後敲擊回車進入到命令行中對應的該文件目錄
在命令行中輸入
rclone authorize "onedrive"
會自動調用本機瀏覽器定向到Microsoft登陸頁面
成功登錄後會彈出SUCCESS頁面
返回到你剛才的命令行裡面,就可以查看獲取到的access_token了(人工打碼最為致命)
2.在Linux上配置rclone
首先安裝unzip 解壓工具
yum install unzip -y
安裝rclone
curl https://rclone.org/install.sh | sudo bash
提示“rclone v1.50.2 has successfully installed”安裝完成
在命令行中輸入:
rclone config
進入rclone配置菜單,根據提示進行選擇
# rclone config2020/01/18 11:55:18 NOTICE: Config file "/root/.config/rclone/rclone.conf" not found - using defaultsNo remotes found - make a new onen) New remotes) Set configuration passwordq) Quit confign/s/q> n #新建name> ojbk #起名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 / JottaCloud \\ "jottacloud"17 / Koofr \\ "koofr"18 / Local Disk \\ "local"19 / Mail.ru Cloud \\ "mailru"20 / Mega \\ "mega"21 / Microsoft Azure Blob Storage \\ "azureblob"22 / Microsoft OneDrive \\ "onedrive"23 / OpenDrive \\ "opendrive"24 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH) \\ "swift"25 / Pcloud \\ "pcloud"26 / Put.io \\ "putio"27 / QingCloud Object Storage \\ "qingstor"28 / SSH/SFTP Connection \\ "sftp"29 / Transparently chunk/split large files \\ "chunker"30 / Union merges the contents of several remotes \\ "union"31 / Webdav \\ "webdav"32 / Yandex Disk \\ "yandex"33 / http Connection \\ "http"34 / premiumize.me \\ "premiumizeme"Storage> 22 #選擇22是Microsoft OneDrive** See help for onedrive backend at: https://rclone.org/onedrive/ **Microsoft App Client IdLeave blank normally.Enter a string value. Press Enter for the default ("").client_id> #留空Microsoft App Client SecretLeave blank normally.Enter a string value. Press Enter for the default ("").client_secret> #留空Edit advanced config? (y/n)y) Yesn) Noy/n> n #輸nRemote configUse auto config? * Say Y if not sure * Say N if you are working on a remote or headless machiney) Yesn) Noy/n> n #輸nFor 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> {"access_token":"xxxxxxxxxxxxxxxxxxxx","expiry":"2020-01-18T12:39:21.6954039+08:00"} #輸入在win下獲取到的tokenChoose 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 #選擇1Found 1 drives, please select the one you want to use:0: OneDrive (business) id=xxxxxxxxChose drive to use:> 0 #選擇0Found drive 'root' of type 'business', URL:https://xxxx.sharepoint.com/personal/xxxx/DocumentsIs that okay?y) Yesn) Noy/n> y #輸入y--------------------[ojbk]type = onedrivetoken = {"access_token":"qwertyuiop","expiry":"2020-01-18T12:39:21.6954039+08:00"}drive_id = asdfghjkldrive_type = business--------------------y) Yes this is OKe) Edit this remoted) Delete this remotey/e/d> y #輸入yCurrent remotes:Name Type==== ====ojbk onedrivee) Edit existing remoten) New remoted) Delete remoter) Rename remotec) Copy remotes) Set configuration passwordq) Quit confige/n/d/r/c/s/q> q #輸入q退出
3.在Linux新建掛載目錄
在根目錄下新建一個od的文件夾,並給予對應權限(我給的稍微大了點)
4.掛載並設置開機自啟
下載腳本
wget -N --no-check-certificate https://raw.githubusercontent.com/x91270/Centos/master/rcloned
修改對應項
命令行輸入vim rcloned,按i進入編輯模式
NAME="" #創建的rclone名,本文此處填ojbk
REMOTE="" #遠程掛載地址對應的文件夾,是你OneDrive對應的具體目錄
LOCAL="" #在本機上的掛載地址
修改完成後,先按esc推出編輯模式,再按:wq保存推出
設置開機自啟
mv rcloned /etc/init.d/rcloned #移動rcloned到init(開機啟動目錄)下
chmod +x /etc/init.d/rcloned #給rcloned可執行權限
chkconfig rcloned on #設置自啟動
bash /etc/init.d/rcloned start #啟動rclone
5.查看服務器空間
命令行輸入:
df -h
會發現多了5T的存儲哦
6.幻想
有了這5TB的存儲空間,搭建個NAS,做個私人網盤,或者當作大盤雞。。。。。都輕鬆搞定,最重要的是數據不會丟(不保證),因為你的數據是存到微軟那邊啦~
閱讀更多 自然科學的數學原理 的文章