banner
xingli

xingli

猫娘爱好者

Mounting OneDrive cloud storage

Mounting Onedrive to Linux System#

1. Get Token#

Download Rclone on a Windows computer, download link: https://rclone.org/downloads/, then unzip it and use cmd to enter the unzipped folder.

rclone.exe authorize "onedrive"

Then it will redirect to the login page of the browser. Enter your account password to log in successfully, and the cmd command prompt will return your token.
The token enclosed in brackets is what you need to copy and save for later use.

2. Install Onedrive on Linux#

Official script provided:

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

image

3. Configuration#

After installation, enter:

rclone config

You will see:

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>

Enter n to create a new configuration.
You can enter any name for name,
Then the type of the mounted service will appear as follows:

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>

Enter the number directly. For example, if I want to mount OneDrive, I can enter 28,
client_id can be left as default by pressing Enter,
client_secret can also be left as default by pressing Enter,
Then the selection of OneDrive region will appear as follows:

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"

You can enter 1 to select global,
Then it is the selection of advanced configuration, as follows:

123dit advanced  config? (y/n)
y) Yes
n) No (default)

You can enter n,
Then it is the selection of auto configuration, as follows:

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

You can enter n,
Here you need to obtain the authorization code:

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:

Then copy the token saved just now, including the {} at the beginning and end, and paste it into the Linux terminal.
Then it is the selection of OneDrive type, as follows:

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"

You can enter 1,
Then the found OneDrive account will be displayed, as follows:

12Found 1  drives,  please  select  the  one  you  want  to  use:
0: OneDrive (business) id=b!b_xnJJqyBMSVPjgvhvbP8XmJ_M_dMjhzrbhnaWknnbKqNBm8MTqM3kvEtW67P

Enter the number according to the prompt,
Here it will search for the account based on the number you entered, as follows:

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

After confirming that it is correct, enter y,
Then the configuration information you selected will be displayed. After confirming that it is correct, enter y to save the configuration.

4. Mounting#

Enter:

rclone mount configName:OneDriveLocation dir --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000

Where configName is the configuration name, OneDriveLocation is the OneDrive directory to be mounted, and dir is the local directory to be mounted to.
For example, if I want to mount a configuration named myonedrive to the /myonedrive directory on the local machine,
If there is no directory, create it first: mkdir myonedrive
I can write it like this:

nohup rclone mount myonedrive:/ /root/myonedrive --vfs-cache-mode writes --vfs-cache-max-age 10s --onedrive-chunk-size 100M >/dev/null 2>&1 &

Here I am mounting the entire OneDrive cloud storage, so I write the root directory of OneDrive /.
After the mounting is completed, no content will be displayed. You can open another terminal and enter df -h to check the disk space, as follows:
image
Mounting successful!!
Some systems may have a significant delay in mounting. Wait for about 30 seconds and try again. Generally, if there is no error, there should be no problem.
Common commands:

rclone copy – Copy
rclone sync – Sync, synchronize the content of a directory to the cloud storage directory
rclone move – Move, move files in a directory to the cloud storage, and delete the files in the source directory by default
rclone purge – Delete the path and all files
rclone delete – Delete all files in the path without deleting the path
rclone mkdir – Create a directory
rclone rmdir – Delete a directory
rclone check – Check if the target file matches the source file
rclone ls – List all files and file sizes in the specified path
rclone lsl – Only list the modification time, size, and path of the object
rclone lsd – Only list directories
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.