How To Mount OneDrive In Linux Using Rclone (Supports Business And Personal Accounts)
Microsoft OneDrive doesn't have an official client application for Linux, but you can access your OneDrive files from a file manager on Linux thanks to a third-party tool called Rclone. This article explains how to mount OneDrive in Linux using Rclone.
Microsoft OneDrive (previously SkyDive) is a cloud storage / file synchronization service, part of the Office Online suite. It offers 5 GB of storage free of charge, with additional storage available with a paid subscription.
Rclone is "rsync for cloud storage". It can synchronize files not only from your filesystem to the cloud (and the other way around), but also from one cloud storage service to another. The tool supports a wide variety of cloud storage services, from Google Drive to Amazon Drive and S3, ownCloud, Yandex Disk, and many others.
Besides on demand file synchronization, Rclone supports mounting any supported cloud storage systems as a file system with FUSE. While this feature exists for some time, it's still considered experimental, so use it with care.
After mounting Microsoft OneDrive, you'll be able to access it from your file manager, be it Nautilus (Files), Nemo, Caja, etc. The behavior is similar to the one explained on our article about Google Drive: Mounting Google Drive On Xfce Or MATE Desktops (Ubuntu, Linux Mint). As a side note, you can also use Rclone to mount Google Drive in Linux.
Rclone supports OneDrive for Business / Office 365. However, if the organization is in an unmanaged state (not verified by the domain owner), you won't be able to mount OneDrive using Rclone with FUSE. Such accounts can be used with Sharepoint though. See this page for more information.
In case you want to sync your OneDrive files with a local folder on Linux, you can use OneDrive Free Client Fork which allows having the files on the disk after the sync is performed, allowing access even when the computer is offline, hich is not the case when mounting OneDrive on Linux.
OneDrive Rclone mount limitations:
Also, renaming folders doesn't seem to work, at least on my system. I'm not sure if this is a Rclone issue or limitation, since Rclone is supposed to support renaming folders in general.
These instructions should work not only on any Linux distribution (from Ubuntu, Linux Mint, or Debian, to Arch Linux, Fedora, openSUSE, and so on), but also on FreeBSD and macOS. It even works on Windows but you'll need WinFsp.
Related: Cryptomator Secures Your Cloud Storage Data (Open Source, Multi-Platform Client-Side Encryption Tool)
1. Install Rclone.
You can download Rclone binaries from here. For Linux you'll find generic binaries, as well as DEB and RPM binaries.
I don't recommend installing the Rclone Snap package (even if you use Ubuntu), because it fails to find the
This was apparently fixed a while back but it looks like the issue occurs again.
2. Add a new OneDrive remote to Rclone. The instructions below may seem long but it only takes a few seconds to set it up.
To start adding the OneDrive remote to Rclone, use this command to enter the Rclone configuration mode:
Rclone will display a list of options from which you need to select the
Next, it will prompt you to enter a name for the new remote. Enter the name you want to use (I'm using
After pressing the
For the next two steps, press
Next, you'll be asked if you want to edit advanced config. Enter "n" unless you have some advanced settings in mind:
Depending on your setup, you'll have to enter auto configuration or manual for the next step. For most users, type
A new tab should open in your default web browser, asking you to give Rclone access to your OneDrive account. Allow it and you can close the tab.
Rclone runs a webserver on your local machine (on port 53682) to retrieve the authentication token. You may need to unblock it temporarily if you use a firewall.
Now you'll have to enter your account type. For most users, enter
You'll see an account (multiple in some special cases) listed, like this:
Enter
You should now reach this screen - enter
Now you'll need to check if everything is correct and save the settings by typing
And finally, quit the Rclone configuration by typing
3. Create a new folder on your system that will be used to mount Microsoft OneDrive.
I suggest creating a folder called
4. Mount OneDrive (with Rclone using FUSE) as a file system.
To mount Microsoft OneDrive using Rclone, use this command:
Where
The mount command uses
You can stop and unmount it by pressing
5. (Optional) Mount OneDrive on system startup
To mount OneDrive on startup, open Startup Applications. This depends on the desktop environment you're using so I'll list some of them below and how to access startup applications to add a new entry:
After clicking
There are other ways of mounting OneDrive automatically, like adding a line in your
Microsoft OneDrive (previously SkyDive) is a cloud storage / file synchronization service, part of the Office Online suite. It offers 5 GB of storage free of charge, with additional storage available with a paid subscription.
Rclone is "rsync for cloud storage". It can synchronize files not only from your filesystem to the cloud (and the other way around), but also from one cloud storage service to another. The tool supports a wide variety of cloud storage services, from Google Drive to Amazon Drive and S3, ownCloud, Yandex Disk, and many others.
Besides on demand file synchronization, Rclone supports mounting any supported cloud storage systems as a file system with FUSE. While this feature exists for some time, it's still considered experimental, so use it with care.
After mounting Microsoft OneDrive, you'll be able to access it from your file manager, be it Nautilus (Files), Nemo, Caja, etc. The behavior is similar to the one explained on our article about Google Drive: Mounting Google Drive On Xfce Or MATE Desktops (Ubuntu, Linux Mint). As a side note, you can also use Rclone to mount Google Drive in Linux.
Rclone supports OneDrive for Business / Office 365. However, if the organization is in an unmanaged state (not verified by the domain owner), you won't be able to mount OneDrive using Rclone with FUSE. Such accounts can be used with Sharepoint though. See this page for more information.
In case you want to sync your OneDrive files with a local folder on Linux, you can use OneDrive Free Client Fork which allows having the files on the disk after the sync is performed, allowing access even when the computer is offline, hich is not the case when mounting OneDrive on Linux.
OneDrive Rclone mount limitations:
- Any files deleted with Rclone are moved to the trash because Microsoft doesn't provide an API to permanently delete files or empty the trash
- OneDrive is case insensitive, so you can't have two files with the same names but different cases in the same folder (example:
MyFile.txt
andmyfile.txt
can't be in the same folder). - OneDrive doesn't support some characters that are not allowed in filenames on Windows operating systems. Rclone maps these characters to identical looking Unicode equivalents, like
?
to?
Also, renaming folders doesn't seem to work, at least on my system. I'm not sure if this is a Rclone issue or limitation, since Rclone is supposed to support renaming folders in general.
These instructions should work not only on any Linux distribution (from Ubuntu, Linux Mint, or Debian, to Arch Linux, Fedora, openSUSE, and so on), but also on FreeBSD and macOS. It even works on Windows but you'll need WinFsp.
Related: Cryptomator Secures Your Cloud Storage Data (Open Source, Multi-Platform Client-Side Encryption Tool)
Mount OneDrive as a file system in Linux using Rclone
1. Install Rclone.
You can download Rclone binaries from here. For Linux you'll find generic binaries, as well as DEB and RPM binaries.
I don't recommend installing the Rclone Snap package (even if you use Ubuntu), because it fails to find the
fusermount
executable, even if it's installed with --classic
. When using the Snap package, you'll get an error similar to the one below when trying to mount a cloud storage service supported by Rclone:failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH
This was apparently fixed a while back but it looks like the issue occurs again.
2. Add a new OneDrive remote to Rclone. The instructions below may seem long but it only takes a few seconds to set it up.
To start adding the OneDrive remote to Rclone, use this command to enter the Rclone configuration mode:
rclone config
Rclone will display a list of options from which you need to select the
New remote
option by entering n
and pressing the Enter
key:$ rclone config
Current remotes:
Name Type
==== ====
mega mega
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> n
Next, it will prompt you to enter a name for the new remote. Enter the name you want to use (I'm using
onedrive
as the name in these instructions):name> onedrive
After pressing the
Enter
key, a list of supported cloud storage services is displayed. You need to select the Microsoft OneDrive option by entering its corresponding number (19
right now but it may change in the future, as more cloud storage services are added to Rclone):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 / A stackable unification remote, which can appear to merge the contents of several remotes
\ "union"
2 / Alias for a 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 / Dropbox
\ "dropbox"
9 / Encrypt/Decrypt a remote
\ "crypt"
10 / FTP Connection
\ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
12 / Google Drive
\ "drive"
13 / Hubic
\ "hubic"
14 / JottaCloud
\ "jottacloud"
15 / Koofr
\ "koofr"
16 / Local Disk
\ "local"
17 / Mega
\ "mega"
18 / Microsoft Azure Blob Storage
\ "azureblob"
19 / Microsoft OneDrive
\ "onedrive"
20 / OpenDrive
\ "opendrive"
21 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
22 / Pcloud
\ "pcloud"
23 / QingCloud Object Storage
\ "qingstor"
24 / SSH/SFTP Connection
\ "sftp"
25 / Webdav
\ "webdav"
26 / Yandex Disk
\ "yandex"
27 / http Connection
\ "http"
Storage> 19
For the next two steps, press
Enter
without entering any information since there's no need to enter the Microsoft App Client ID or Secret: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>
Next, you'll be asked if you want to edit advanced config. Enter "n" unless you have some advanced settings in mind:
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n
Depending on your setup, you'll have to enter auto configuration or manual for the next step. For most users, type
y
to use the auto configuration: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> y
A new tab should open in your default web browser, asking you to give Rclone access to your OneDrive account. Allow it and you can close the tab.
Rclone runs a webserver on your local machine (on port 53682) to retrieve the authentication token. You may need to unblock it temporarily if you use a firewall.
Now you'll have to enter your account type. For most users, enter
1
, which corresponds to a OneDrive Personal or Business account: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
You'll see an account (multiple in some special cases) listed, like this:
Found 1 drives, please select the one you want to use:
0: (personal) id=f119f51f0a00000
Chose drive to use:> 0
Enter
0
and press Enter.You should now reach this screen - enter
y
to continue.Found drive 'root' of type 'personal', URL: https://onedrive.live.com/?cid=0f119f51f000000
Is that okay?
y) Yes
n) No
y/n> y
Now you'll need to check if everything is correct and save the settings by typing
y
:
[onedrive]
type = onedrive
token = {"access_token":"GoKSt5YMioiuCWX1KOuo8QT0Fwy+Y6ZeX7M","token_type":"bearer","refresh_token":"7OMvoEAO3l*8BbhS2AMxpTbJW0Y6np9cdql!bwEdYAhJ6XBG0tnR0UK","expiry":"2018-07-26T15:15:13.696368366+03:00"}
drive_id = f119f51f0a00000
drive_type = personal
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y
And finally, quit the Rclone configuration by typing
q
:Current remotes:
Name Type
==== ====
onedrive 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
3. Create a new folder on your system that will be used to mount Microsoft OneDrive.
I suggest creating a folder called
OneDrive
in your home directory. The instructions below will be using this as the mount point (~/OneDrive
).4. Mount OneDrive (with Rclone using FUSE) as a file system.
To mount Microsoft OneDrive using Rclone, use this command:
rclone --vfs-cache-mode writes mount onedrive: ~/OneDrive
Where
onedrive
is the name of the Rclone remote, followed by :
(we've used exactly onedrive
in the instructions above so you can use precisely that for the command), and ~/OneDrive
is the folder where you want to mount OneDrive on your system.The mount command uses
--vfs-cache-mode writes
because according to the Rclone documentation, "many applications won't work with their files on an Rclone mount" without this or --vfs-cache-mode full
. The Rclone file caching section explains this in detail.You can stop and unmount it by pressing
Ctrl + C
to close Rclone.5. (Optional) Mount OneDrive on system startup
To mount OneDrive on startup, open Startup Applications. This depends on the desktop environment you're using so I'll list some of them below and how to access startup applications to add a new entry:
- Gnome / Unity: search for
Startup Applications
in the Dash / applications thingy, and in Startup Applications clickAdd
- Xfce: launch
Session and Startup
from the menu, go to theApplication Autostart
tab and clickAdd
- MATE: launch
Startup Applications
from the menu, and clickAdd
After clicking
Add
, use the following:- Name: Rclone OneDrive Mount
- Command:
sh -c "rclone --vfs-cache-mode writes mount onedrive: ~/OneDrive"
There are other ways of mounting OneDrive automatically, like adding a line in your
/etc/fstab
file, using systemd, etc. As a starting point you can use the examples from google-drive-ocamlfuse, as they should also work for Rclone.