For some requirement, I need to mount OneDrive instead of Syncing files through onedrive-d. Also, I need need a command line solution to automate something in my scripts. Can anyone help on this ?

I tried to mount it from usual mount command, but failed. Please note, I am not an expert of Linux command line, so please help.

Thanks in advance.

-- Ninad


Mount OneDrive on Ubuntu

This instruction follows RCLONE - Microsoft OneDrive

1. Download and install Rclone

sudo apt install rclone

or download the latest one

wget https://downloads.rclone.org/v1.42/rclone-v1.42-linux-amd64.deb
sudo apt install ./rclone-v1.42-linux-amd64.deb

2. Add a new OneDrive remote to Rclone

rclone config
  • Select the New remote option by entering n and pressing the 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
  • Enter a name for the new remote, here onedrive is used:

    name> onedrive
  • After pressing the Enter, a list of supported cloud storage services is displayed. You need to select the Microsoft OneDrive option by entering its corresponding number ("16" right now but it may change in the future):

    Type of storage to configure.
    Choose a number from below, or type in your own value
    xx / Microsoft OneDrive
       \ "onedrive"
    Storage> onedrive
  • For the next two steps, press Enter without entering any information since there's no need to enter the Microsoft App Client ID or Secret:

    Microsoft App Client Id 
    Leave blank normally.
    Microsoft App Client Secret - leave blank normally.
  • Choose the OneDrive account type (enter b for Business or p for Personal OneDrive accounts):

    Remote config
    Choose OneDrive account type?
     * Say b for a OneDrive business account
     * Say p for a personal OneDrive account
    b) Business
    p) Personal
    b/p> p
  • Depending on your setup, you'll have to enter auto configuration or manual for the next step. For desktop users, type y to use the auto 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 your default web browser, asking you to give Rclone access to your OneDrive account. Allow it and you can close the tab.

    Rclone runs a webserver on your local machine (on port 53682) to retrieve the authentication token. You may need to unblock it temporarily if you use a firewall.

  • Now you'll need to check if everything is correct and save the settings by typing y:

    type = onedrive
    client_id = 
    client_secret = 
    token = {"access_token":"GoKSt5YMioiuCWX1KOuo8QT0Fwy+Y6ZeX7M","token_type":"bearer","refresh_token":"7OMvoEAO3l*8BbhS2AMxpTbJW0Y6np9cdql!bwEdYAhJ6XBG0tnR0UK","expiry":"2018-07-26T15:15:13.696368366+03:00"}
    y) Yes this is OK
    e) Edit this remote
    d) Delete this remote
    y/e/d> y
  • Exit the Rclone configuration by typing 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

mkdir ~/OneDrive 

4. Mount OneDrive

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

You can stop and unmount it by pressing Ctrl + c to close Rclone.

5. (Optional) Mount OneDrive on system startup

To mount OneDrive on startup, open Startup Applications, and in Startup Applications click Add.

After clicking Add, use the following:

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

There are other ways of mounting OneDrive automatically, like adding a line in your /etc/fstab file, using systemd, etc.

| improve this answer | |
  • 2020/04/28 22:56:44 Fatal error: unknown flag: --vfs-cache-mode – Tony Apr 29 at 3:02
  • --vfs-cache-mode is a known flag according to the rclone manual! Please add your command line and the name of your drive in the post. In order to see if your rclone configuration is rigth type rclone lsd <your drive name>: – abu_bua Apr 29 at 13:23
  • @Tony is correct. That option is not valid and is not in the current man page. – Juan Jimenez Jul 2 at 18:03

As far as I know there is no easy solution to mount OneDrive in any gnu/linux distribution.

You can use Storage Made Easy (SMEStorage) to mount several providers in one folder. It is free up to 3 providers, but it is not opensource.

You can also use the app provided or mount it via webdav (Nautilus - Connect to server) and use the instructions provided in: CloudDAV

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.