Using RClone to Mount Your OneDrive Folder in Linux
If you have a Microsoft Office 365 account you know that it comes with 1TB of storage. You can use RClone to mount your OneDrive locally on your Linux machine so that you can read and write documents stored there.
- Install rclone from whatever package repository that your Linux operating system uses.
- Follow the instructions here to configure your OneDrive environment. The instructions are rather straightforward and a couple pieces of extra advice follows:
In the first section, type n
for a new
installation and give your mountpoint a name:
$ rclone config
No remotes found - make a new one
n) New remote
s) Set configuration password
q) Quit config
n/s/q>
n
name> remote
In the next section just press enter to accept the default:
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Now you have to choose the vendor of the service you’re configuring. There are a lot of selections hereso just look for Microsoft OneDrive, in my case it was 26:
Choose a number from below, or type in your own value
1 / 1Fichier
\ "fichier"
2 / Alias for an existing remote
\ "alias"
etc.
25 / Microsoft Azure Blob Storage
\ "azureblob"
26 / Microsoft OneDrive
\ "onedrive"
27 / OpenDrive
\ "opendrive"
28 / OpenStack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
Storage> 26
The next couple of selections are just the default, so press the Enter key:
OAuth Client Id
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_id>
OAuth Client Secret
Leave blank normally.
Enter a string value. Press Enter for the default ("").
client_secret>
Now select the global choice:
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> 1
Select the default here:
Edit advanced config? (y/n)
y) Yes
n) No (default)
y/n> n
Select the default here:
Remote 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
y/n> y
Now the browser should open and you should provide your Microsoft credentials:
If your browser doesn't open automatically go to the following link: http://127.0.0.1:53682/auth?state=<some long key here>
Log in and authorize rclone for access
Waiting for code...
Got code
Select 1 for Personal or Business:
Choose 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"
Your choice> 1
Select the drive number from the list, there will probably be only one to choose from, and then select the default:
Found 1 drives, please select the one you want to use:
0: (personal) id=<id key>
Chose drive to use:> 0
Found drive 'root' of type 'personal', URL: https://onedrive.live.com/?cid=<id key>
Is that okay?
y) Yes (default)
n) No
y/n> y
Now rclone will list out the configuration information and ask for confirmation. If all looks good then select y and you’re done:
--------------------
[remote]
type = onedrive
region = global
token = <some long token string here>
drive_id = <some long token string here>
drive_type = personal
--------------------
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> y
Current remotes:
Name Type
==== ====
remote 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
- Now you should be able to list the contents of the OneDrive directory on the console:
$ rclone lsd remote:
-1 2023-06-23 04:15:30 3 .Trash-1000
-1 2023-07-23 15:21:03 1 Apps
-1 2017-09-20 15:34:22 0 Attachments
-1 2023-07-04 23:53:04 0 Desktop
-1 2023-07-23 14:33:10 472 Documents
-1 2023-07-22 02:43:07 135 Documents from Macbook
-1 2019-11-08 21:22:23 0 Email attachments
-1 2019-11-08 21:22:23 0 Movies
-1 2023-07-23 03:39:57 53 Music
-1 2023-07-02 16:34:04 37 Pictures
-1 2022-05-24 10:39:02 2 Public
-1 2021-08-01 13:47:30 2 SyncFusion
-1 2023-06-20 11:41:24 4 Videos
If for some reason it isn’t mounted you can mount it manually with the following command:
$ rclone --vfs-cache-mode writes mount remote: ~/OneDrive &
[2] 69267