Before we start let’s get this out of the way…ENCRYPT EVERYTHING!
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 an awesome third-party tool called rclone. This post explains how to mount OneDrive in Linux using Rclone.
STEP 1: Install Rclone You can download Rclone binaries from here. For Linux you’ll find generic binaries, as well as DEB, OpenBSD 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 the –classic switch. When using the Snap package, you’ll get an error similar to the one demonstrated here 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
Additionally I also don’t recommend installing rclone via your distro’s repository. In the case of Mint & Ubuntu, the version provided was old enough to generate and error when attempting to mount any drive onedrive or webdav. Upgrading to the latest version cured this issue.
STEP 2: Add a new OneDrive remote to Rclone. To initiate 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 New remote option by entering n and pressing the Enter key:
You will then be prompted to enter a name for the new remote. Enter the name you want to use (I used onedrive as used in the developers instructions to keep it simple):
After pressing the Enter key, a list of supported cloud storage services is displayed (this app isn’t limited to onedrive). Select the *Microsoft OneDrive option by entering its corresponding number (18 is the menu item at the time of this writing).
For the following steps, just press Enter without entering any information as there’s no requirement to enter the Microsoft App Client ID or Secret: </code></pre>
Microsoft App Client Id - leave blank normally. client_id> Microsoft App Client Secret - leave blank normally. client_secret>`
You can also just Enter n asking to edit advanced config. Unless you have there are advanced changes you would like to make of course!
Edit advanced config? (y/n) y) Yes n) No y/n> n
Based on your system configuration, you’ll have to enter auto configuration or manual for the next step. For most users, type y to use the auto configuration: </code></pre>
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 browser tab will open in your default web browser, asking you to login to OneDrive and authenticate, followed by a permissions screen to grant Rclone access to your OneDrive account. Allow it and you can close the tab.
Rclone listens on incoming TCP PORT 53682 to retrieve the authentication token. You may need to allow this temporarily if your firewall is on. And if it’s not? IT SHOULD BE!
Next you’ll be prompted to select the account type. at the time of this writing OneDrive “Personal or Business” is option 1. Enter 1, which corresponds to a OneDrive Personal or Business account.
You’ll then be presented with the account information displayed, like this:
Found 1 drives, please select the one you want to use: 0: (personal) id=f666777f51f0ab0000 Choose drive to use:> 0
Enter 0 (Zero) and press Enter.
You will then be presented with 2 additional confirmation screens:
'Found drive 'root' of type 'personal', URL: https://onedrive.live.com'?cid=f666777f51f0ab0000 Is that okay? y) Yes n) No y/n> y
Enter y to continue, and you will move to the final confirmation screen:
[onedrive] type = onedrivetoken="access_token":"BfiuEBYUBdfOuo8QT0Fwy+Y6sdZeXfs7M","token_type"," refresh_token"expiry":"2018-12-26T15:15:13.7876468366-05:00"} drive_id = f666777f51f0ab0000 drive_type = personal -------------------- y) Yes this is OK e) Edit this remote d) Delete this remote y/e/d> y
Enter y to continue, and you will move to the final configuration screen:
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
Enter q to quit, and we can move on to creating our mount point and mounting the drive.
STEP 3: Create a new folder on your system that will be used to mount Microsoft OneDrive.
In the spirit of simplicity I created the folder OneDrive in the home directory. The commmand below will be using this as the mount point (~/OneDrive).
STEP 4: Mount OneDrive (with Rclone using FUSE) as a file system.
To mount Microsoft OneDrive using Rclone, use the following command:
rclone --vfs-cache-mode writes mount onedrive: ~/OneDrive
Following the command onedrive is the name of the Rclone remote drive, followed by our mount point ~/OneDrive which is the folder where you will mount OneDrive in the system.
The mount command uses the argument –vfs-cache-mode writes as this is a dependency for most applications. Further details related to vfs cache can be found in the official Rclone documentation. As mentioned at the start of this posting, if you are using an older version packaged in your distro you will get an error using this argument, stating that “–vfs-cache-mode writes does not exist” .
You can stop and unmount it by pressing Ctrl + C to close Rclone.
STEP 5: Auto Mount OneDrive on system startup
To mount OneDrive on startup, open Startup Applications. There are dependencies on the desktop environment being used for this article I have documented using Gnome/Unity.
Gnome / Unity: search for Startup Applications in the applications search, and in Startup Applications click Add:
After clicking Add, input the following items in the dialogue screen:
Name: Rclone OneDrive Mount Command: sh -c "rclone --vfs-cache-mode writes mount onedrive: ~/OneDrive"
While there are a number of ways to auto-mount the drive, I chose to take this route for the sake of simplicity. As most reading this can make the changes with little effort.
#Foss #Linux #Cloud #HowTo