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
3 Answers
Mount OneDrive on Ubuntu
This instruction follows RCLONE - Microsoft OneDrive
- Download and install Rclone
sudo apt install rcloneor download the latest one
wget
sudo apt install ./rclone-v1.42-linux-amd64.deb2. Add a new OneDrive remote to Rclone
rclone configSelect 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> nEnter a name for the new remote, here
onedriveis used:name> onedriveAfter 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> onedriveFor 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
bfor Business orpfor 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> pDepending 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 configon 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> yIf 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> yExit 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
- Create a new folder
mkdir ~/OneDrive - Mount OneDrive
rclone --vfs-cache-mode writes mount onedrive: ~/OneDriveYou can stop and unmount it by pressing Ctrl + c to close Rclone.
- (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.
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
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: ~/onedriveadd sh /home/$(USER)/.onedive.sh to start up application