Set up an Rclone Mount (using ssh)
December 5th, 2019, 21:30

Written by sc4nd4l

Introduction

In this tutorial we are going to setup an rclone mount via ssh. This will allow you to access files that are on a network location. Rclone can work with Google Drive, Google Cloud Storage, Amazon S3, Dropbox, Amazon Drive, Microsoft OneDrive, Hubic, Backblaze B2 and some more.


Step 1 - Install Prerequisites

Make sure that you have all the needed dependencies such as:

  • An updated system - Start by making sure that your system is up-to-date by doing the following command:
    sudo apt-get update && sudo apt-get upgrade
  • Fuse (needed to be able to mount on UNIX systems)
    sudo apt-get install -y fuse
  • Screen (needed to be able to run operations in the background of the system)
    sudo apt-get install -y screen
  • Other tools
    sudo apt-get install -y curl unzip nano

* -y skips the confirmation you get while installing the packages


Step 2 - Install Rclone

Install rclone on your system:

sudo curl https://rclone.org/install.sh | sudo bash

Make sure that fuse supports --allow-other flag, by typing:

sudo nano /etc/fuse.conf

When the fuse.conf file is open, make sure you remove the # before the word user_allow_other. Once you have done this press Ctrl+X and then press y to save.


Step 3 - Add new Rclone remote (Google Drive)

  1. Type: rclone config
  2. Type: n Press: Enter
  3. Type: <nameofyourteamdrive> Press: Enter
  4. Type: drive Press: Enter
  5. Paste you client_id and client_secret
    (To paste in PuTTY simply right click, to copy in PuTTY simply highlight the text. Do not press Ctrl+C or Ctrl+V)
  6. Type: drive Press: Enter
  7. Press: Enter
  8. Press: Enter
  9. Type: n Press: Enter
  10. Type: n Press: Enter
  11. Highlight the link with your mouse
    (Note: Do not press Ctrl+C if you are using PuTTY, highlighting the text with your mouse will copy it).
    Then paste the link into a browser window, login with your Google account and press Allow.
    It will give you a code. Copy that code and paste it back into your terminal (if you are using PuTTY, use right click). Press: Enter
  12. Type: y Press: Enter
  13. Look in the list for your teamdrive and type the number next to this Team Drive. If this is the only Team Drive in your account it will be the number 1, so Type: 1 Press: Enter
  14. Type: y Press: Enter
  15. Type: q Press: Enter

More providers can be found on rclone.org

You have successfully setup a new Rclone remote.


Step 4 - Run Rclone mount with screen

  1. Create a new folder for rclone cache
    mkdir -p /mnt/shared/config/rclone/cache
  2. Create a new empty folder to mount on
    mkdir /mnt/shared/fusemounts/<yourteamdrivename>
  3. Create a new named screen
    screen -S mount
  4. Run the following command:
    rclone mount <yourteamdrivename>:/ /mnt/shared/fusemounts/<yourteamdrivename> --timeout 1h --tpslimit 10 --dir-cache-time 5m --vfs-cache-mode writes --vfs-cache-max-age 1h --vfs-cache-max-size 100G --vfs-read-chunk-size-limit 1024M --vfs-read-chunk-size 26M --buffer-size 16M --cache-dir /mnt/shared/config/rclone/cache --allow-other --gid 911 --uid 911
    Make sure you change <yourteamdrivename> with the folder you created on Step 4.1
  5. You can detach from the screen instance by pressing Ctrl+A, then letter D.

You can now check to see if the media files are mounted by typing:

cd /mnt/shared/fusemounts/<yourteamdrivename>
ls

If you can see your remote files it looks like everything is mounted correctly.

Important Notes

  • If you want to re-attach to the screen:
    screen -r mount
  • If you want to unmount fuse itself:
    sudo fusermount -uz "/mnt/shared/fusemounts/<yourteamdrivename>"
  • Do not use "Repair Permissions" when you have a mounted folder running.
  • Do not restart apps (like Plex) when you have a mounted folder, as it will cause your app to hang. You will have to unmount folder first, restart the app (let it fully start) and then mount folder again.


Conclusion

You have successfully setup Rclone and mounted it on a folder. Your apps should be able to see this folder.

You can ask more on our #rclone-plexdrive channel on Discord.