Sync Microsoft OneDrive in Linux
Problem:
I need to use my Microsoft One Drive on Linux as a local hard disk and keep it sync.
Solution:
There is no official OneDrive client for Linux computers. The functionality of drive syncing can be achieved by using the third party software RClone. RClone requires a Linux computer with a GUI interface (it will not work on command line only installs).
¡Important! RClone is a third party software not supported by Microsoft.
We are following the solution in two parts:
- PART 1. Install and setup rclone and OneDrive on Linux
- PART 2. Mount the One Drive in a Linux
PART 1. Install and setup rclone and OneDrive on Linux
There is no official OneDrive client for Linux computers. The functionality of drive syncing can be achieved by using the third party software RClone. RClone requires a Linux computer with a GUI interface (it will not work on command line only installs).
¡Important! RClone is a third party software not supported by Microsoft.
-
Open a terminal window and install RClone using the following command.
curl https://rclone.org/install.sh | sudo bash -
Start configuring OneDrive in RClone by running the config command.
rclone config -
You will be prompted with configuration options. Choose
nto create a new remote.>>>No remotes found, make a new one? n) New remote s) Set configuration password q) Quit config n/s/q> n -
Enter
OneDriveITCas the name for the remote. -
For storage type, enter
onedrive(or the corresponding number). -
Leave client_id and client_secret empty. Press
enterkey to leave the fields blank.>>>Option client_id. OAuth Client Id. Leave blank normally. Enter a value. Press Enter to leave empty. client_id> >>>Option client_secret. OAuth Client Secret. Leave blank normally. Enter a value. Press Enter to leave empty. client_secret> -
Enter
1for the region. -
Press
nto skip advanced configuration.>>>Edit advanced config? y) Yes n) No (default) y/n> n -
Press
yto authenticate using a your default web browser.Use web browser to automatically authenticate rclone with remote? * Say Y if the machine running rclone has a web browser you can use * Say N if running rclone on a (remote) machine without web browser access If not sure try Y. If Y failed, try N. y) Yes (default) n) No y/n> y -
A browser window will open to a Microsoft login screen. Login using your TecNM email address and NetID password.


-
After logging in, close the browser window and go back to the terminal that is running RClone.
-
When prompted for
config_type(Type of connection) enteronedriveor1. -
When prompted for
Option config_driveidchoose2(Documentos (business)). -
You’ll be prompted to connect to the root of your OneDrive. Press
yto continue.>>>Drive OK? Found drive "root" of type "business" URL: URL: https://itculiacanedu-my.sharepoint.com/personal/d24171315_culiacan_tecnm_mx/Documents y) Yes (default) n) No y/n> y -
Press
yto confirm that the remote is ok.>>>y) Yes this is OK (default) e) Edit this remote d) Delete this remote y/e/d> y -
Press
qto close the remote configuration procedure.Current remotes: Name Type ==== ==== OneDriveITC 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 -
Create a
OneDriveITCdirectory in your home folder to mount the remote that you just created.mkdir ~/OneDriveITC -
Mount the remote by using the command:
rclone --vfs-cache-mode writes mount OneDriveITC: ~/OneDriveITC & -
Close the terminal window. You should now have OneDrive mounted in your file system.
¡IMPORTANT! If you reboot the computer you will need to remount the remote using the command in step 17.
PART 2. Mount the One Drive in a Linux at startup
-
You can verify that your remote is working by using:
rclone ls OneDriveITC:It will appear a listing remote contents:

- Get the config location using:
$ rclone config file /home/rogelio/.config/rclone/rclone.confCopy the file path!
- Set read permissions to the config file :
chmod 640 /home/rogelio/.config/rclone/rclone.confPlease, replace (paste) the config file path.
- To mount, try this command:
rclone mount --vfs-cache-mode full OneDriveITC: ~/OneDriveITC --config /home/rogelio/.config/rclone/rclone.confPlease, replace (paste) your config path.
Try to copy or create files for testing that mount point is working.
Note:
vfs-cache-modehas two options:fullorwrites.fullis recommended if you want to reduce latency, but the space in HDD will be up.writesis the option if mainly you will write. -
In these next steps, we’ll create a systemd service. Go to
/etc/systemd/system/and create a new file calledrclonemountITC.serviceand paste this in:[Unit] Description=Rclone mount ITC AssertPathIsDirectory=/media/rogelio/DATA-HD-4TB/OneDriveITC After=network-online.target [Service] Type=simple ExecStart=/usr/bin/rclone mount \ --config=/home/rogelio/.config/rclone/rclone.conf \ --vfs-cache-mode full \ OneDriveITC: /media/rogelio/DATA-HD-4TB/OneDriveITC ExecStop=/bin/fusermount -u /media/rogelio/DATA-HD-4TB/OneDriveITC Restart=always RestartSec=10 User=rogelio [Install] WantedBy=default.targetReplace
rogelioby your username in your local computer. -
Save it and execute it by running
systemctl start rclonemountITC. You can view if it failed or not by runningsystemctl status rclonemountITC.To make it execute on next boot, execute
systemctl enable rclonemountITCand it should run on the next reboot.If you do any changes to
rclonemountITC.servicefile, make sure to executesystemctl daemon-reloadto reload any changes you’re done.
Fixing things
After terminating rclone, FUSE usually doesn’t dismount correctly. We’ll have to run fusermount -u <mountpoint> to unmount it correctly. If it says its busy, force it by umount -l <mountpoint> and then using the fusermount command again.
Source:
- Knowledge Base - University of Connecticut
https://kb.uconn.edu/space/IKB/26050527301/Setting+up+OneDrive+on+Linux
- Mounting Onedrive with Rclone mount on startup with Systemd
https://thunderysteak.github.io/rclone-mount-onedrive
- Forum - Rclone is very slow to opening files
https://forum.rclone.org/t/rclone-is-very-slow-to-opening-files/33416/4
- Rclone cache
https://rclone.org/commands/rclone_mount/#vfs-file-caching
- Rclone OneDrive setup