How to Sync Microsoft OneDrive with Linux

sync-onedrive-linux-featured

Sometimes lately it can be necessary to use propriety products. Open source enthusiasts would love to have a cloud-based storage facility, but the fact remains that companies like Google, Amazon, Dropbox and Microsoft have cornered the cloud storage market. They offer reliable products for free, and this mean that yes, they will scan or read your files in order to comply with legal requests or to serve adverts. It is a fact of life, but this doesn’t mean you shouldn’t use them.

OneDrive is Microsoft’s cloud based storage offering, and even though it is naturally suited to the Windows platform, it will connect with Linux-based machines with little effort. There are a number of ways to do this, and this is where OneDrive-d comes into play.

OneDrive-d is a CLI-based client developed by Xiangyu Bu. It lets users sync quickly and easily with OneDrive (much in the same vein as RSync does).

In order to install OneDrive-d, first you need to set up git, unless you already have it. Head to the Terminal and enter:

Next, you need to clone the OneDrive-d files to the hidden folder:

You will then need to run the installer:

Once this is done, we need ngrok. Despite the name, this isn’t the next Marvel franchise. ngrok is a third-party platform for relaying webhook integration. OneDrive-d uses ngrok to allow webhook requests from the OneDrive API to bypass port-forwarding and the like.

Grab a copy of ngrok and extract. Now copy it to your directory:

After you have done this, now you need to authorize OneDrive-d with Microsoft so it can access your account. Simply enter the following in the Terminal:

ms-auth

This launches the interactive wizard that will let you configure the program. You need to copy the URL into your browser to complete the authentication. Once this is done, you will be presented with a blank white page. This serves to give you the new URL you need. Copy this and paste it into the Terminal at the prompt.

Next, you need to set the drive to be used with the following command:

This runs through some interactive settings – follow the prompts, and finish up the configuration. To make it easier, leave the default path as is, and press Y to sync that folder. Start OneDrive-d by typing:

You should start to see your files sync locally. If you store large files, as I do, it will take some time, so please be patient. You can check on the progress by navigating to Home – OneDrive within your file manager.

By default, OneDrive-d doesnt start when the user logs in for the first time. The daemon is essentially dumb unless we change that. Head to the Terminal once more and tell the system that you want GNOME to start on login with:

onedrive-startup

This will open the GNOME session configuration where you can add OneDrive-d as a startup program. The command is:

Now your OneDrive will sync with your Linux system. However, how do you sync OneDrive to your setup, and do you prefer other tools? Let us know in the comments section below.

Image credit: Microsoft OneDrive website under a magnifying glass by DepositPhotos

9 comments

  1. The ‘onedrived start’ returned ERROR: Child exited immediately with exit code 127.

    Should this be run as sudo?

  2. Follow-up: I tried running ‘onedrived start’ as sudo and now I get the following:

    WARNING:root:Failed to load config file: [Errno 2] No such file or directory: ‘/root/.config/onedrived/onedrived_config_v2.json’. Use default.
    Starting onedrived … FAILED
    ERROR: Child exited immediately with exit code 1

    Am I missing something? I followed all the steps in the tutorial and everything seemed to go correctly, but the onedrive daemon won’t start.

  3. I get an error

    ~/.odd$ sudo python3 ./setup.py install
    Traceback (most recent call last):
    File “./setup.py”, line 11, in
    from setuptools import setup, find_packages
    ModuleNotFoundError: No module named ‘setuptools’

    This is on Ubuntu 18.10. Any suggestions to fix it?

  4. Found the solution by trial and error to the No module named ‘setuptools’ problem

    sudo apt install python3 -y
    sudo apt install python3-pip -y
    pip3 install –upgrade pip setuptools

    Then
    sudo python3 ./setup.py install
    works as stated.

  5. I tried this procedure and I got till:
    sudo python3 ./setup.py install
    then I got the message :
    Traceback (most recent call last):
    File “./setup.py”, line 11, in
    from setuptools import setup, find_packages
    ModuleNotFoundError: No module named ‘setuptools’
    what ś nect???

  6. I recently started using onedrive, and now I can’t live without it. Hoping Microsoft brings one drive to Linux soon.

  7. Thanks for the simplified procedure and it works perfectly.

    Is there anyway to see the sync status like how many files are synched?

    ex: 10/100

Leave a Comment

Yeah! You've decided to leave a comment. That's fantastic! Check out our comment policy here. Let's have a personal and meaningful conversation.

Sponsored Stories