linux 获取命令行返回的数据_如何在linux服务器免费获取TB级存储空间

开开心心买的云服务器准备部署自己的博客,什么?只有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/

linux 获取命令行返回的数据_如何在linux服务器免费获取TB级存储空间_第1张图片

解压下载包,进入解压后目录

linux 获取命令行返回的数据_如何在linux服务器免费获取TB级存储空间_第2张图片

在蓝色处删除所有内容,输入cmd后敲击回车进入到命令行中对应的该文件目录

linux 获取命令行返回的数据_如何在linux服务器免费获取TB级存储空间_第3张图片

linux 获取命令行返回的数据_如何在linux服务器免费获取TB级存储空间_第4张图片

在命令行中输入

rclone authorize "onedrive"

会自动调用本机浏览器定向到Microsoft登陆页面

linux 获取命令行返回的数据_如何在linux服务器免费获取TB级存储空间_第5张图片

成功登录后会弹出SUCCESS页面

linux 获取命令行返回的数据_如何在linux服务器免费获取TB级存储空间_第6张图片

返回到你刚才的命令行里面,就可以查看获取到的access_token了(人工打码最为致命)

linux 获取命令行返回的数据_如何在linux服务器免费获取TB级存储空间_第7张图片

2.在Linux上配置rclone

首先安装unzip 解压工具

yum install unzip -y

安装rclone

curl https://rclone.org/install.sh | sudo bash

提示“rclone v1.50.2 has successfully installed”安装完成

linux 获取命令行返回的数据_如何在linux服务器免费获取TB级存储空间_第8张图片

在命令行中输入:

rclone config

进入rclone配置菜单,根据提示进行选择

# rclone config
2020/01/18 11:55:18 NOTICE: Config file "/root/.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    #新建
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 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>     #留空
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n     #输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
n) No
y/n> n    #输n
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> {"access_token":"xxxxxxxxxxxxxxxxxxxx","expiry":"2020-01-18T12:39:21.6954039+08:00"}  #输入在win下获取到的token
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    #选择1
Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=xxxxxxxx
Chose drive to use:> 0    #选择0
Found drive 'root' of type 'business', URL:

https://xxxx.sharepoint.com/personal/xxxx/Documents
Is that okay?
y) Yes
n) No
y/n> y    #输入y
--------------------
[ojbk]
type = onedrive
token = {"access_token":"qwertyuiop","expiry":"2020-01-18T12:39:21.6954039+08:00"}
drive_id = asdfghjkl
drive_type = business
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y    #输入y
Current remotes:

Name                 Type
====                 ====
ojbk                 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    #输入q退出

3.在Linux新建挂载目录

在根目录下新建一个od的文件夹,并给予对应权限(我给的稍微大了点)

a45ef06f567f7e962ff9008135d6cf55.png

4.挂载并设置开机自启

下载脚本

wget -N --no-check-certificate https://raw.githubusercontent.com/x91270/Centos/master/rcloned

linux 获取命令行返回的数据_如何在linux服务器免费获取TB级存储空间_第9张图片

修改对应项

命令行输入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的存储哦

linux 获取命令行返回的数据_如何在linux服务器免费获取TB级存储空间_第10张图片

6.幻想

有了这5TB的存储空间,搭建个NAS,做个私人网盘,或者当作大盘鸡。。。。。都轻松搞定,最重要的是数据不会丢(不保证),因为你的数据是存到微软那边啦~

欢迎关注微信公众号

linux 获取命令行返回的数据_如何在linux服务器免费获取TB级存储空间_第11张图片

你可能感兴趣的:(linux,获取命令行返回的数据)