Skip to content

Instantly share code, notes, and snippets.

@murilonevesdev
Forked from Gyarbij/rclone.onedrive.md
Last active November 28, 2024 20:20
Show Gist options
  • Select an option

  • Save murilonevesdev/b366facc2b109cf270c46577c8b09249 to your computer and use it in GitHub Desktop.

Select an option

Save murilonevesdev/b366facc2b109cf270c46577c8b09249 to your computer and use it in GitHub Desktop.

Revisions

  1. murilonevesdev revised this gist Nov 28, 2024. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions rclone.onedrive.md
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,4 @@
    CHANGE LEGEND: (
    Thanks for sharing this, gyarbij!
    I've changed a few things to make it work on my machine (Debian 13 testing).
    ----------------------
    you MUST replace these in the service file)
    CHANGE LEGEND: (you MUST replace these in the service file)

    * USERNAME = your actual username e.g. gyarbij
    * I recommend changing odrive.service to the name of eache drive if you have multiple mount points.
  2. murilonevesdev revised this gist Nov 28, 2024. 1 changed file with 9 additions and 6 deletions.
    15 changes: 9 additions & 6 deletions rclone.onedrive.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,8 @@
    CHANGE LEGEND: (you MUST replace these in the service file)
    CHANGE LEGEND: (
    Thanks for sharing this, gyarbij!
    I've changed a few things to make it work on my machine (Debian 13 testing).
    ----------------------
    you MUST replace these in the service file)

    * USERNAME = your actual username e.g. gyarbij
    * I recommend changing odrive.service to the name of eache drive if you have multiple mount points.
    @@ -45,20 +49,19 @@ After=network-online.target
    AssertPathIsDirectory=/mnt/odrive
    [Service]
    Type=notify
    Environment=RCLONE_CONFIG=/home/USERNAME/.config/rclone/rclone.conf #check USERNMAE
    Type=simple
    RestartSec=10
    ExecStart=/usr/bin/rclone mount odm: /mnt/odm \
    ExecStart=/usr/bin/rclone mount OneDrive:/ /mnt/onedrive \ #I've named my remote OneDrive in my first "rclone config" call.
    --config=/home/USERNAME/.config/rclone/rclone.conf \ #check USERNAME
    --allow-other \
    --allow-non-empty \
    --dir-cache-time 5000h \
    --cache-dir=/mnt/rclonecache \
    --volname odrive \
    --vfs-cache-mode full \
    --vfs-cache-max-size 10G \
    --vfs-cache-poll-interval 1m \
    --buffer-size 512M \
    --dir-cache-time 72d \
    --dir-cache-time 60m \ #service was complaining about the "d" for days, so I just used a smaller time, 60m
    --umask 002 \
    --vfs-read-chunk-size 250M \
    --vfs-read-chunk-size-limit off
  3. @Gyarbij Gyarbij created this gist Nov 29, 2023.
    115 changes: 115 additions & 0 deletions rclone.onedrive.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,115 @@
    CHANGE LEGEND: (you MUST replace these in the service file)

    * USERNAME = your actual username e.g. gyarbij
    * I recommend changing odrive.service to the name of eache drive if you have multiple mount points.
    * If you already have rclone mounts check Step #2 then skip to Step #4 and place your mount point at ```#MOUNT```


    Steps for RClone systemd to autostart on boot

    1. Install fusermount (if not already installed)
    ```
    sudo apt install fuse3
    ```
    2. Allow non-root users to mount filesystems
    ```
    sudo nano /etc/fuse.conf
    ```
    Uncomment (remove the) # from the line:
    ```allow_other```

    3. Make the requisite directories for mount and cache.
    ```
    sudo mkdir /mnt/rclonecache
    ```
    or do all directories at once. You will need to ```chown``` regardless.

    ```
    sudo mkdir /mnt/{odrive,rclonecache}
    ```
    ```
    sudo chown -R USERNAME:USERNAME /mnt/{odrive,rclonecache}
    ```

    4. Create the service(s):
    ```
    sudo nano /etc/systemd/system/odrive.service
    ```

    5. Copy the below BASIC example to the service file created/opened above:
    ```
    [Unit]
    Description=RClone Service
    Wants=network-online.target
    After=network-online.target
    AssertPathIsDirectory=/mnt/odrive
    [Service]
    Type=notify
    Environment=RCLONE_CONFIG=/home/USERNAME/.config/rclone/rclone.conf #check USERNMAE
    RestartSec=10
    ExecStart=/usr/bin/rclone mount odm: /mnt/odm \
    --allow-other \
    --allow-non-empty \
    --dir-cache-time 5000h \
    --cache-dir=/mnt/rclonecache \
    --volname odrive \
    --vfs-cache-mode full \
    --vfs-cache-max-size 10G \
    --vfs-cache-poll-interval 1m \
    --buffer-size 512M \
    --dir-cache-time 72d \
    --umask 002 \
    --vfs-read-chunk-size 250M \
    --vfs-read-chunk-size-limit off
    ExecStop=/bin/fusermount -uz /mnt/odrive #MOUNT
    Restart=on-failure
    User=USERNAME #change
    Group=USERNAME #change
    [Install]
    WantedBy=multi-user.target
    ```

    6. Save and then exit the file
    ```
    ctrl+o | ctrl+x
    ```

    7. Run the follwoing commands in order to enable and then start the service:

    ```
    sudo systemctl daemon-reload
    ```

    ```
    sudo systemctl enable odrive
    ```

    ```
    sudo systemctl start odrive
    ```

    8. To see if the service is running:
    ```
    systemctl status odrive
    ```

    9. To see if the drive is mounted run:
    ```
    df -H
    ```

    10. Reboot and repeat step 7 for a final sanity check!

    11. Prevent Docker from starting before mounts:
    ```
    sudo systemctl edit docker.service
    ```

    ```
    [Service]
    #ExecStartPre=/bin/sleep 30
    RequiresMountsFor=/mnt/odrive
    ```