1.获取Token
在Windows电脑上下载Rclone,下载地址:https://rclone.org/downloads/ ,然后解压,使用cmd进入解压后的文件夹
./rclone.exe authorize "onedrive"
然后会跳转到浏览器的登录页面,输入账号密码登录成功后cmd命令框就会返回你的token
框起来的就是要复制保存的,后期会用
2.Linux安装onedirve
官方提供的脚本
curl https://rclone.org/install.sh | bash
3.配置
安装好之后输入:
rclone config
会看到:
2022/04/27 09:01:17 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 可以随便输入,
然后会出现挂载的服务类型,如下:
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
1 / 1Fichier
\ (fichier)
2 / Akamai NetStorage
\ (netstorage)
3 / Alias for an existing remote
\ (alias)
4 / Amazon Drive
\ (amazon cloud drive)
5 / Amazon S3 Compliant Storage Providers including AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Lyve Cloud, Minio, RackCorp, SeaweedFS, and Tencent COS
\ (s3)
6 / Backblaze B2
\ (b2)
7 / Better checksums for other remotes
\ (hasher)
8 / Box
\ (box)
9 / Cache a remote
\ (cache)
10 / Citrix Sharefile
\ (sharefile)
11 / Compress a remote
\ (compress)
12 / Dropbox
\ (dropbox)
13 / Encrypt/Decrypt a remote
\ (crypt)
14 / Enterprise File Fabric
\ (filefabric)
15 / FTP Connection
\ (ftp)
16 / Google Cloud Storage (this is not Google Drive)
\ (google cloud storage)
17 / Google Drive
\ (drive)
18 / Google Photos
\ (google photos)
19 / Hadoop distributed file system
\ (hdfs)
20 / Hubic
\ (hubic)
21 / In memory object storage system.
\ (memory)
22 / Jottacloud
\ (jottacloud)
23 / Koofr, Digi Storage and other Koofr-compatible storage providers
\ (koofr)
24 / Local Disk
\ (local)
25 / Mail.ru Cloud
\ (mailru)
26 / Mega
\ (mega)
27 / Microsoft Azure Blob Storage
\ (azureblob)
28 / Microsoft OneDrive
\ (onedrive)
29 / OpenDrive
\ (opendrive)
30 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ (swift)
31 / Pcloud
\ (pcloud)
32 / Put.io
\ (putio)
33 / QingCloud Object Storage
\ (qingstor)
34 / SSH/SFTP Connection
\ (sftp)
35 / Sia Decentralized Cloud
\ (sia)
36 / Storj Decentralized Cloud Storage
\ (storj)
37 / Sugarsync
\ (sugarsync)
38 / Transparently chunk/split large files
\ (chunker)
39 / Union merges the contents of several upstream fs
\ (union)
40 / Uptobox
\ (uptobox)
41 / Webdav
\ (webdav)
42 / Yandex Disk
\ (yandex)
43 / Zoho
\ (zoho)
44 / http Connection
\ (http)
45 / premiumize.me
\ (premiumizeme)
46 / seafile
\ (seafile)
Storage>
直接输入序号,比如我挂载的是 OneDrive 就可以输入 28 ,
client_id 可以直接回车默认,
client_secret 也可以直接回车默认,
然后会出现 OneDrive 区域选择,如下:
1234567891011Choose 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"
可以直接输入 1 选择全球,
然后是选择是否进行高级配置,如下:
123dit advanced config? (y/n)
y) Yes
n) No (default)
可以输入 n ,
接着是自动配置选择,如下:
123456Remote 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
可以输入 n ,
这里需要获取授权码:
Copy1234567891011For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rclone
version recommended):
rclone authorize "onedrive"
Then paste the result below:
然后复制刚刚保存的token包括首尾的 {} ,到 Linux 终端粘贴。
然后是选择 OneDrive 的类型,如下:
123456789101112131415Choose a number from below, or type in an existing value
1 / 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"
可以输入 1 ,
然后会显示找到的 OneDrive 账户,如下:
12Found 1 drives, please select the one you want to use:
0: OneDrive (business) id=b!b_xnJJqyBMSVPjgvhvbP8XmJ_M_dMjhzrbhnaWknnbKqNBm8MTqM3kvEtW67P
根据提示输入序号,
这里会根据你输入的序号查找账户,如下:
1234Found drive 'root' of type 'business', URL: https://xxx-my.sharepoint.com/personal/changbin_xxx_onmicrosoft_com/Documents
Is that okay?
y) Yes (default)
n) No
确认无误后输入 y ,
接着会显示你选择的配置信息,确认无误后输入 y 保存配置。
4.挂载
输入:
rclone mount configName:OneDriveLocation dir --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000
其中的 configName 就是配置名称,OneDriveLocation 就是要挂载的 OneDrive 目录,dir 就是要挂载到的本地目录。
例如我要把一个名为 myonedrive 的配置挂载到本地的 /myonedrive 目录
没有目录的话先创建:
mkdir myonedrive
我可以这样写:
nohup rclone mount myonedrive:/ /root/myonedrive --vfs-cache-mode writes --vfs-cache-max-age 10s --onedrive-chunk-size 100M >/dev/null 2>&1 &
我这里挂载的是整个 OneDrive 网盘,所以我写的是 OneDrive 的根目录 / 。
挂载完成后不会显示任何内容,可以再开一个终端,输入 df -h 查看磁盘空间,如下:
成功挂载!!
常用指令
rclone copy – 复制
rclone sync – 同步 将目录内容同步到网盘目录
rclone move – 移动 将目录内文件移动到网盘,默认删除路径文件
rclone purge – 删除路径及所有文件
rclone delete – 删除路径所有文件但不删除路径
rclone mkdir – 创建目录
rclone rmdir – 删除目录
rclone check – 检查目标文件与源文件是否匹配
rclone ls – 列出指定路径下的所有的文件以及文件大小
rclone lsl – 仅列出对象的修改时间,大小和路径
rclone lsd – 仅列出目录
暂无评论内容