print friendly version

How to...

Accessing OneDrive files on linux using rclone


Install rclone

 

Use the rclone installation script by entering the following command in a terminal window:

 

$ curl https://rclone.org/install.sh | sudo bash

 

Alternative installation instructions are available from the rclone website: https://rclone.org/install/

 

Configuration for use with OneDrive

 

To access OneDrive files using rclone, you need to configure an rclone remote.
A remote can be thought of as a named local configuration of a remote file store (the information required to access OneDrive in this case).

 

1. Run the  rclone config  command in a terminal, using the command:

rclone config

 

2. When presented with the config menu (shown below) press the  n  key followed by  Enter

Config command

 

Provide a name for the new remote, this will be how you will uniquely identify the remotes that you have configured. Below we’ve used the name OneDrive. Then press enter.

Select OneDrive

 

4. Select the type of online account that rclone will be accessing. When prompted, either type  onedrive  or enter the number that corresponds to the onedrive online storage in the output list of available options

Storage type

 

5. Leave the following 2 steps blank (default) by pressing  Enter  for each of them

Leave blank

 

6. Unless you’re already familiar with rclone and require some advanced configuration, enter  n  for the advanced config option

Advanced config

 

7. You can allow rclone to automatically configure the remote by entering  y  for the Remote config prompt

Auto config

 

8. A new tab will appear in your web browser window and present the Microsoft login screen (login.microsoft.com). If the browser tab isn’t automatically opened, a link is provided in the terminal

Unless already logged in, you’ll need to enter your email address in the form of username@sussex.ac.uk and select  Next

Microsoft sign in

 

You will then be redirected to the university’s single sign on login page. Enter your password and then  Sign in

Sussex sign in page

 

When signed a success message will appear in the browser window

Success

 

9. Back in the terminal, choose “onedrive” (or the corresponding number for a onedrive file store, in this case 1) to access

Select OneDrive

 

10. If more than one drive is found, you may now be presented with an option to choose which drive to use. Select the one to use by entering the corresponding number.

Drive number to use

 

11. Information about the chosen drive will appear followed by a confirmation prompt to which, type  y  to confirm

Confirmation prompt

 

12. An overview of your current remotes now includes the newly created OneDrive remote, from here you can exit the configuration menu by pressing  q

Overview

 

Now the remote has been configured there are several commands available which are analogous to common linux command line programs such as  rclone ls ,   rclone touch ,  rclone rmdir  – a full list can be found using   rclone help  or documentation available on the rclone website.

 

Mounting remotes to access files in your file browser

 

A remote can be mounted locally using the rclone mount command as shown below which requires an empty directory to exist to use as the mount point. The “--vfs-cache-mode writes" option enables local caching of files for writing, without this option some files, such as .docx and .xslx files, won’t be writeable.

 

$ mkdir –p ~/Documents/OneDrive

$ rclone mount --vfs-cache-mode writes OneDrive:/ ~/Documents/OneDrive/

 

Once mounted, you should now find the remote mounted within your file browser to allow for GUI interaction with your OneDrive files.

To unmount:

 

$ fusermount -u ~/Documents/OneDrive

 

Automatically mounting onedrive files on system startup

 

You can automate the mounting of our OneDrive files upon login by adding the following lines to the  ~/.profile  file:

 

if ! mountpoint -q ${HOME}/Documents/OneDrive

then

    /usr/bin/mkdir -p ${HOME}/Documents/OneDrive

    /usr/bin/rclone mount \

    --allow-non-empty \

    --config=${HOME}/.config/rclone/rclone.conf \

    --daemon \

    --vfs-cache-mode writes \

    OneDrive:/ ${HOME}/Documents/OneDrive

fi

 

created on 2020-06-22 by Alexander Butler
last updated on 2020-06-22 by Alexander Butler