If you already did follow other instructions (e.g.: https://wiki.ubuntuusers.de/OneDrive/) your sync may be located at an unwanted folder location. (Default equals /root/onedrive/) In order to apply your own settings, stop onedrive and delete the /root/onedrive and /root/.config/onedrive folder and its content.
If you didn’t install onedrive yet, run
sudo apt install onedrive
Start by adding a onedrive.service file into the system folder, in order to automatically launch OneDrive uppon a system restart. Replace my username “thomas” and its group “Thomas” with your environment setup.
sudo nano /etc/systemd/system/onedrive.service
[Unit]
Description=OneDrive Sync
[Service]
WorkingDirectory=/usr/bin/
ExecStart=/usr/bin/onedrive --synchronize -v
Restart=always
RestartSec=30
User=thomas
Group=Thomas
[Install]
WantedBy=multi-user.target
Next we setup the config file for the OneDrive Sync. Be aware, that sync_dir equals the folder you would like to synchronize to. Replace “thomas” with your user’s home directory.
nano /home/thomas/.config/onedrive/config
# Configuration for OneDrive Linux Client
# This file contains the list of supported configuration fields
# with their default values.
# All values need to be enclosed in quotes
# When changing a config option below, remove the '#' from the start of the line
# For explanations of all config options below see docs/USAGE.md or the man page.
#
sync_dir = "/home/thomas/OneDrive/"
# skip_file = "~*|.~*|*.tmp"
# monitor_interval = "300"
# skip_dir = ""
# log_dir = "/var/log/onedrive/"
# drive_id = ""
# upload_only = "false"
# check_nomount = "false"
# check_nosync = "false"
# download_only = "false"
# disable_notifications = "false"
# disable_upload_validation = "false"
# enable_logging = "false"
# force_http_11 = "false"
# force_http_2 = "false"
# local_first = "false"
# no_remote_delete = "false"
# skip_symlinks = "false"
# debug_https = "false"
# skip_dotfiles = "false"
# dry_run = "false"
# min_notify_changes = "5"
# monitor_log_frequency = "5"
# monitor_fullscan_frequency = "10"
# sync_root_files = "false"
# classify_as_big_delete = "1000"
# user_agent = ""
# remove_source_files = "false"
# skip_dir_strict_match = "false"
# application_id = ""
# resync = "false"
# bypass_data_preservation = "false"
Reload the systemctl daemon and enable the ondrive service.
sudo systemctl daemon-reload
systemctl --user enable onedrive
Ensure that the sync_dir is owned by the corresponding user.
sudo chown thomas:thomas /home/thomas/OneDrive -R
Before we are able to “systemctl start onedrive”, we require to launch it once manually, in order to grant access to the remote services. Thus, proceed as follows
onedrive --synchronize
Navigate to the provided link, and paste the callback URL into the console. Once it starts synchronizing, hit CTRL + C.
Onedrive is setup and ready to launch. In order to start OneDrive either type “systemctl –user start onedrive” or restart the system with “shutdown -r 0”.
systemctl --user start onedrive
For more details, read the dev documentation at https://github.com/abraunegg/onedrive/blob/master/docs/USAGE.md
sysctl fs.inotify.max_user_watches
If the “systemctl –user status onedrive” does output
Jun 21 21:07:35 pc onedrive[1365]: sysctl fs.inotify.max_user_watches
Jun 21 21:07:35 pc onedrive[1365]: To change the current max number of watches to 1024 run:
Jun 21 21:07:35 pc onedrive[1365]: sudo sysctl fs.inotify.max_user_watches=1024
simply increase its watch size and restart the service. As an example
sudo sysctl fs.inotify.max_user_watches=1000000
systemctl --user restart onedrive