Brief: A step-by-step tutorial showing how to use the rclone command line tool to synchronize OneDrive in Linux.
There are several cloud storage services available for Linux. There is Dropbox that gives 2 GB of free space. You can also use Mega where you can get 15 GB of free storage.
Microsoft’s own Cloud storage service, OneDrive gives 5 GB of free storage to any Microsoft account holder. The one major problem is that unlike Dropbox and Mega, Microsoft does not provide a desktop client for Linux.
This means that you’ll have to resort to using web browser for accessing your files in OneDrive which is not very convinient.
If you are not afraid of the Linux terminal, let me show you a command line tool rclone that you can use for synchronizing Microsoft OneDrive in Linux.
What is rclone?
Rclone is an open source command line tool that enables you to synchronize a local Linux directory with various cloud storage services.
With rclone, you can backup files to cloud storage, restore files from cloud storage, mirror cloud data, migrate data between cloud services, use multiple cloud storage as disk.
You can use it with Google Drive, OneDrive, Nextcloud, Amazon S3 and over 40 such cloud services.
Rclone is an extensive command line tool and using it could be confusing with so many options. This is why I wrote this tutorial to show you how to use rclone with Microsoft OneDrive.
Update: There is a separate tool called Rclone Browser that makes using rclone easier by providing a graphical user interface.
Sync Microsoft OneDrive in Linux with rclone
Using Rclone in Linux is not that complicated but requires some patience and familiarity with the Linux terminal. You need to tweak the configuration a little to make it work. Let’s see how to do that.
Step 1: Install Rclone
I am using Ubuntu 20.04 in this tutorial but you should be able to follow this tutorial in pretty much any Linux distribution. Just the rclone installation instruction could be different but the rest of steps remains the same.
In Debian/Ubuntu based distributions use:
sudo apt install rclone
For Arch-based distributions, use:
sudo pacman -S rclone
For other distributions, please use your distribution’s package manager.
Step 2: Adding new remote
Once you have installed rclone successfully, you need to configure rclone. Enter the following command in the terminal:
If it’s your first time using rclone, you have to add a new remote to rclone. Select ‘n‘ to add new remote.
Now you have to enter the name of remote. You can enter any name here that matches the cloud service so that it is easy to identify. I am using ‘onedrive‘.
Step 3: Select cloud service you want to sync with rclone
After entering name and hitting enter, you will see a list of cloud services like Google cloud storage, Box, One Drive and others.
You have to enter the number of the service you want to use. In this case, it’s ‘One Drive’. Make sure you enter the correct number.
As you don’t need to enter client ID or secret ID hit Enter twice.
Next enter ‘N’ for selecting no for advanced configuration. Of course, if you want to configure something very specific, you can go ahead with Y.
When you’re asked for ‘Use auto config’, press Y.
Step 4: Login to OneDrive account
When you enter ‘y’ and hit enter, your default browser will open and here you have to log into your Microsoft account. And if it asks for permission click on ‘yes’.
Step 5: Enter account type
Now you have to select account type. For most of the users it will be the first one, ‘One drive Personal or business’. I believe it is personal so go with 1.
After that, you will get a list of ‘Drives’ associated with your account. So, for the most part, you need to select ‘0’ to select your drive and enter ‘Y‘ for yes in next step.
It will ask for one last time if this configuration is okay? Hit ‘Y’ if it is.
And then enter ‘q’ to exit the Rclone configuration menu.
Step 5: Mounting OneDrive int file manager
Create folder in your home directory where you will mount OneDrive. I will name the folder “OneDrive”. You can name it whatever you want, but please make sure you change the name to yours in the commands.
Create a new folder with mkdir command in your home directory or wherever you want:
Now you have to use the following command:
rclone --vfs-cache-mode writes mount "one drive": ~/OneDrive
In above command “one drive” is the name of the “remote”, so you should use the correct name there if yours is different. You can check the name of the “remote” in step 2 of this tutorial.
This command will mount one drive in given location and will continue to run in terminal. When you stop the process with,
ctrl + c the one drive will be unmounted.
To mount one drive on startup, follow the next step below.
Step 6: Mount One Drive on startup
Every Linux distribution gives some way to manage startup application. I am using Ubuntu’s Startup Application Preferences tool here.
Open “Startup Applications“. And click on “Add“. Now, in the command field, enter the following:
sh -c "rclone --vfs-cache-mode writes mount \"one drive\": ~/OneDrive"
That’s it. Now, you can easily use OneDrive on Linux without any hiccups.
As you can see, using OneDrive in Linux with rclone takes some effort. If you want an easy way out, get a GUI tool like Insync. and use OneDrive natively in Linux.
I hope you find this tutorial helpful. If you have any questions or suggestion, we’ll be happy to help you out.
Computer engineer, FOSS lover, lower level computing enthusiast. Believe in helping others and spreading knowledge. When I get off from computer (it rarely happens) I do painting, reading and watching movies/series. Love the work of Sir Arthur Conan Doyle, J. R. R. Tolkien and J. K. Rowling. BTW, I use Arch.