How to use Rclone to mount OneDrive in Linux (supports corporate and personal accounts)

Microsoft OneDrive There is no official client application for Linux, but with the help of a third-party tool called Rclone, you can access OneDrive files from the file manager on Linux. This article explains how to mount OneDrive in Linux using the following command clone.

Microsoft OneDrive (formerly known as SkyDive) is a cloud storage/file synchronization service that is part of the Office Online suite. It provides 5 GB of storage space for free, and paid subscriptions can provide additional storage space.
Rclone is “rsync for cloud storage.” Not only can it sync files from the file system to the cloud (and vice versa), it can also sync files from one cloud storage service to another. The tool supports multiple cloud storage services, from Google Drive to Amazon Drive and S3, ownCloud, Yandex Disk, etc.
In addition to on-demand file synchronization, Rclone also supports using FUSE to mount any supported cloud storage system as a file system. Although this feature has been around for a while, it is still considered an experimental feature, so please use it with caution.
After mounting Microsoft OneDrive, you can access it from the file manager, whether it is Nautilus (file), Nemo, Caja, etc. Its behavior is similar to that described in our article about Google Drive: Xfce or MATE desktop (Ubuntu, Linux Mint). Alternatively, you can use Rclone to mount Google Drive on Linux.
Rclone supports OneDrive for Business/Office 365. However, if your organization is in an unmanaged state (not verified by the domain owner), you will not be able to install OneDrive using Rclone with FUSE. However, such accounts can be used with Sharepoint. See This one If you want to synchronize OneDrive files with local folders on Linux, you can use OneDrive Free Client Fork, which allows you to save files on disk after performing a synchronization, which can be accessed even when the computer is offline, install on Linux This is not the case with OneDrive.
OneDrive Rclone installation restrictions:

  • Since Microsoft does not provide an API to permanently delete files or empty the trash, all files deleted with Rclone will be moved to the trash.
  • OneDrive is not case sensitive, so you cannot have two files with the same name but different capitalization in the same folder (for example: MyFile.txt with myfile.txt Cannot be in the same folder).
  • OneDrive does not support certain characters that are not allowed in file names on the Windows operating system. Rclone maps these characters to the Unicode equivalent of the same appearance, for example ? to

Also, at least on my system, renaming the folder does not seem to work. I’m not sure if this is Rclone’s problem or its limitations, because Rclone is should Usually supports renaming folders.
These instructions apply not only to any Linux distribution (from Ubuntu, Linux Mint or Debian to Arch Linux, Fedora, openSUSE, etc.), but also to FreeBSD and macOS. It even works On windows But you need WinFsp. Related: Cryptomator protects your cloud storage data (open source, multi-platform client 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 will find common binaries as well as DEB and RPM binaries.
I do not recommend installing the Rclone Snap package (even if you use Ubuntu) because it cannot be found fusermount Executable file, even if it is related to --classic. When using the Snap software package, when trying to install a cloud storage service supported by Rclone, an error similar to the following error will appear:

failed to mount FUSE fs: fusermount: exec: "fusermount": executable file not found in $PATH

This is obviously fixed for a while, but looks like problem Occurs again 2. Add the new OneDrive to Rclone remotely. The instructions below seem to be very long, but it only takes a few seconds to set them up.
To start adding OneDrive remotely to Rclone, use the following command to enter Rclone configuration mode:

rclone config

Rclone will display a list of options from which you need to choose New remote Enter the following options n then press 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 the name of the new remote control. Enter the name you want to use (I am using onedrive As the name in these instructions):

name> onedrive

After pressing Enter Key, a list of supported cloud storage services will be displayed. You need to select the Microsoft OneDrive option by entering the corresponding number (19 Now, but 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 No need to enter any information, because there is no need to enter 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 will be asked if you want to edit the advanced configuration. Enter “n” unless you have some advanced settings:

Edit advanced config? (y/n)
y) Yes
n) No
y/n> n

Depending on your settings, you must enter automatic configuration or manually proceed to the next step. For most users, type y Use automatic 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 the default web browser, asking you to grant Rclone access to the OneDrive account. Allow it and you can close the tab.
Rclone runs a web server on the local computer (port 53682) to retrieve the authentication token. If you use a firewall, you may need to temporarily unblock it.
Now, you must 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 will see a listed account (multiple in some special cases) as shown below:

Found 1 drives, please select the one you want to use:
0:  (personal) id=f119f51f0a00000
Chose drive to use:> 0

Input 0 Then press Enter.
You should now reach this screen-enter y Then say.

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 need to check that everything is correct and save the settings by typing the following 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

Finally, enter the following to exit Rclone configuration: 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 the system, which will be used to mount Microsoft OneDrive.
I suggest creating a file called OneDrive In your home directory. The following instructions will use this as the installation point (~/OneDrive). 4. Mount OneDrive (use FUSE with Rclone) as a file system.
To mount Microsoft OneDrive using Rclone, use the following command:

rclone --vfs-cache-mode writes mount onedrive: ~/OneDrive

Where onedrive Is the name of the Rclone remote control, followed by : (We have fully used onedrive In the above description, so you can use it precisely for commands), and ~/OneDrive It is the folder where OneDrive is to be installed on the system.
Use the mount command --vfs-cache-mode writes Because according to the Rclone documentation, “Without this feature, “many applications will not be able to use their files on Rclone mounts” --vfs-cache-mode full. Clone File cache This section will explain this in detail.
You can press stop and uninstall it Ctrl + C Close Rclone. 5. (Optional) Mount OneDrive at system startup
To install OneDrive at startup, open the “launch application”. It depends on the desktop environment you use, so I will list some of them below, and how to access the startup application to add new entries:

  • Gnome / Unity: Search Startup Applications In Dash/App, then in Launch App, click Add
  • Xfce: start Session and Startup Go from the menu Application Autostart Label and click Add
  • MATE: start Startup Applications From the menu and click Add

After clicking Add, Please use the following command:

  • Name: Mount Rclone OneDrive
  • Command: sh -c "rclone --vfs-cache-mode writes mount onedrive: ~/OneDrive"

There are other ways to automatically install OneDrive, such as /etc/fstab Files, use systemd, etc. As a starting point, you can use example From google-drive-ocamlfuse, because they should also apply to Rclone.

Source

Sidebar