31

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

6 Answers6

38

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
      [snip]
      ... 
      ...
      xx / Microsoft OneDrive
         \ "onedrive"
      ...
      ...
      [snip]
      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.
      client_id> 
      Microsoft App Client Secret - leave blank normally.
      client_secret>
    
  • 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. If you are setting up on a remote or headless machine type n (you will need to run rclone config on a machine with browser access and copy/paste an authentication token later:

      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
    
  • If you are mounting on a local machine: 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.
    .
    If setting up a remote or headless machine: rclone will provide a terminal command that you will need to execute on a machine with a web browser. This command will provide you with an authentication key that you should paste into this session. See these instructions for more details.

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

      [onedrive]
      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

  1. Create a new folder

mkdir ~/OneDrive 
  1. Mount OneDrive

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

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

  1. (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.

Nick S
  • 171
abu_bua
  • 11,313
1

For any WSL users, it is easy. Without doing anything at all, I could access OneDrive at

/mnt/c/Users/my_user_name/OneDrive/

which uses the standard Windows OneDrive and filesystem drivers.

0

extra

If you are on xfce4 (Manjaro)

create /home/$(USER)/.onedive.sh give excute permission

#!/bin/sh
sleep 3
rclone --vfs-cache-mode writes mount onedrive: ~/onedrive

add sh /home/$(USER)/.onedive.sh to start up application

0

Just use

onedrive --monitor

after proper installation: https://itslinuxfoss.com/how-to-install-and-use-onedrive-on-ubuntu-20-04/

You can put it in e.g. the Startup apps.

0

As @Allexj mentioned in his comment to the question there's also a program called "onedriver", which mounts your OneDrive as a network storage, so it doesn't keep local files synched to the cloud but instead just lists your online files in a local directory of your choosing and downloads them whenever you actually need them. I downloaded onedriver through the OpenSUSE Build Service, which builds the package for you for Debian, OpenSUSE, Raspbian and Ubuntu and allows you to install them as a matching package for your system.
I tested it and it seems great, especially since my school's OneDrive has 1TB of storage (so I regularly use it to move large files from one computer to another) and with the solution I previously had I had to ensure that my laptop was offline during that time so it wouldn't waste its SSD space on OneDrive.

The package installs two commands, onedriver (for command-line access) and onedriver-launcher (the GUI for onedriver).

Lampe2020
  • 153
0

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

Danilo
  • 127