Microsoft’s own Cloud storage service, OneDrive, gives any Microsoft account holder 5 GB of free storage.
This means that you’ll have to resort to using a web browser for accessing your files in OneDrive, which is not very convenient.
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.
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 remain 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 must add a new remote to rclone. Select ‘n‘ to add a new remote.
Now you have to enter the name of the 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 the cloud service you want to sync with rclone
After entering the 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: Log in 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 one last time if this configuration is okay. Hit ‘Y’ if it is.
And then enter ‘q’ to exit the Rclone configuration menu.
Step 6: Mounting OneDrive in the file manager
Create a 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 the 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 the given location and will continue to run in the 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 applications. 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.
Worth the effort?
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 experience and use OneDrive natively in Linux with Insync. It's a closed-source, paid tool but saves you the trouble (and joy) of configuring things manually.
It would have been a lot better if Microsoft provided a native client for Linux. But that wouldn't be very Microsoft-like after all.
This is the reason why I prefer Mega, which provides up to 20 GB of cloud storage for free.
I hope you find this tutorial helpful in getting OneDrive on Linux. If you have any questions or suggestions, we’ll be happy to help you out.