Onedrive Rclone

This guide walks you through setting up Microsoft OneDrive on Linux using rclone.

Prerequisites

  • rclone installed on your Linux system
  • A Microsoft OneDrive account
  • A web browser for authentication

Installation

sudo pacman -S rclone

Configuration Steps

1. Start rclone Configuration

rclone config

2. Create a New Remote

When prompted, select:

  • n for New remote
  • Enter a name for your remote (e.g., OneDrive)

3. Select Storage Type

  • Choose option 38 for Microsoft OneDrive
  • Or type onedrive

4. OAuth Configuration

Leave the following blank (press Enter):

  • client_id
  • client_secret

5. Choose Region

Select your region:

  • 1 for Microsoft Cloud Global (most common)
  • 2 for US Government
  • 3 for Germany
  • 4 for China

6. Authentication

When asked “Use web browser to automatically authenticate?”:

  • Select y (Yes)
  • Your browser will open automatically
  • If it doesn’t, copy and paste the provided URL
  • Log in to your Microsoft account and authorize rclone

7. Select Drive Type

Choose your connection type:

  • 1 for OneDrive Personal or Business (most common)
  • 2 for Root Sharepoint site
  • Other options for advanced configurations

8. Select Drive

If you have multiple drives, select the appropriate one (usually option 1 for your main OneDrive).

9. Confirm Configuration

  • Review the configuration
  • Select y to keep the remote
  • Select q to quit config

Mount Script

Create a script to easily mount your OneDrive:

#!/usr/bin/bash
#   ___             ____       _
#  / _ \ _ __   ___|  _ \ _ __(_)_   _____
# | | | | '_ \ / _ \ | | | '__| \ \ / / _ \
# | |_| | | | |  __/ |_| | |  | |\ V /  __/
#  \___/|_| |_|\___|____/|_|  |_| \_/ \___|
#
rclone --vfs-cache-mode writes mount OneDrive: ~/OneDrive &
notify-send "OneDrive connected" "Microsoft OneDrive successfully mounted"

Save this as onedrive.sh and make it executable:

chmod +x onedrive.sh

Usage

Mount OneDrive

Run your script:

./onedrive.sh

Or manually:

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

Notes

  • The configuration file is stored at ~/.config/rclone/rclone.conf
  • Make sure the mount point directory (~/OneDrive) exists before mounting
  • The --vfs-cache-mode writes flag improves performance for write operations
  • Access tokens are automatically refreshed by rclone

my DevOps Odyssey

“Σα βγεις στον πηγαιμό για την Ιθάκη, να εύχεσαι να ‘ναι μακρύς ο δρόμος, γεμάτος περιπέτειες, γεμάτος γνώσεις.” - Kavafis’ Ithaka.