A Comprehensive Guide to Rclone Mounting and Configuration

rclone mountrclone configurationcloud storage mountfuse installationrclone performance tuning
Published·Modified·

Rclone is a command-line program that supports multiple operating systems including Windows, Linux, and MacOS. It can mount more than 40 types of network storage, making it an invaluable tool for mounting. This article discusses some explanations and precautions regarding Rclone.

Installing Rclone

This article uses CentOS 7 as an example. All commands below are executed on CentOS 7. Rclone is developed using Golang, and the official pre-compiled binary packages make installation very simple. Execute the following command:

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

For production or critical environments, it is recommended to create a separate user to run Rclone. This article does not provide detailed instructions on this. After installation, execute the command rclone -V to check the current version:

[root@bf-xiaoz ~]# rclone -V
rclone v1.53.3
- os/arch: linux/amd64
- go version: go1.15.5

Machine Configuration

The usual practice is to install Rclone on a VPS and mount various cloud storage services (such as OneDrive). This article does not cover storage configuration (assuming you have already added the storage). Rclone mounts cloud storage to the local machine via network mounting. Since it relies on network mounting, performance and stability are naturally inferior to local disks.

Additionally, you may find that Rclone consumes high CPU and memory during use. This is related to the machine's performance and Rclone configuration. For personal use, the recommended machine configuration is:

  • CPU: 2 cores
  • Memory: 1GB or more
  • Disk: At least 30GB

Mount Parameters

Rclone mounting depends on fuse, so it must be installed first:

# Install fuse on CentOS 7
yum -y install fuse

I have already mounted the OneDrive storage and named it od. You can view it using the rclone listremotes command:

[rclone@bf-xiaoz rclone]$ rclone listremotes
od:

The Rclone configuration file is located at $HOME/.config/rclone/rclone.conf, where $HOME is the user's home directory.

[rclone@bf-xiaoz ~]$ ls -l $HOME/.config/rclone/rclone.conf
-rw------- 1 rclone rclone 1876 Dec 27 18:32 /home/rclone/.config/rclone/rclone.conf

The Rclone cache directory is located at $HOME/.cache/rclone. If your server has additional disks mounted, it is recommended to create a symbolic link for this directory to a non-system disk to avoid Rclone consuming too much system disk space during use.

Below, I will explain using my own mount command:

# A complete Rclone mount command
rclone mount od:/file /data/wwwroot/xxx --allow-other --attr-timeout 5m --vfs-cache-mode full --vfs-cache-max-age 24h --vfs-cache-max-size 10G --vfs-read-chunk-size-limit 100M --buffer-size 100M --daemon

Don't be intimidated by the long command above. Let's break it down; it is actually quite simple:

  • rclone mount: The Rclone mount command.
  • od:/file: As mentioned earlier, I pre-configured OneDrive and named it od. od:/file is the path on OneDrive.
  • /data/wwwroot/xxx: The local folder path (recommended to be an empty directory).
  • --allow-other: Allows users other than the current Rclone user to access the mount.
  • --attr-timeout 5m: File attribute cache timeout (size, modification time, etc.). If the machine configuration is low, it is recommended to increase this value appropriately to avoid excessive interaction with the kernel and resource consumption.
  • -vfs-cache-mode full: Enables VFS file caching, which reduces Rclone's interaction with the API and improves file read/write efficiency.
  • --vfs-cache-max-age 24h: VFS file cache duration. Here set to 24 hours; if files are rarely changed, a longer time is recommended.
  • --vfs-cache-max-size 10G: VFS file cache upper limit. It is recommended not to exceed 50% of the current available disk space.
  • vfs-read-chunk-size-limit 100M: Chunk read size. Here set to 100M, which can improve file read efficiency. For example, a 1GB file is roughly divided into 10 chunks for reading, but this also increases the number of API requests.
  • --buffer-size 100M: Memory cache. If your memory is small, you can lower this value; if memory is large, you can increase it appropriately.
  • --daemon: Run in the background.

After understanding the meaning of the parameters above, you can adjust them according to your machine's configuration to avoid Rclone unexpectedly consuming too much CPU or memory. For more parameter explanations, refer to the official documentation: https://rclone.org/commands/rclone_mount/

Unmounting

Normally, you can simply use the umount command to unmount:

#/path/to/local/mount is the mount directory
umount /path/to/local/mount

Or use fusermount:

fusermount -u /path/to/local/mount

If you are prompted that the disk is busy, you may have to forcefully kill the process. The command is:

# Kill the process
pgrep 'rclone'|xargs kill -9
# Unmount again
umount /path/to/local/mount

Summary

  • For critical environments, it is recommended to create a separate rclone user to run it.
  • The Rclone cache directory is recommended to be set to a non-system partition (/).
  • If the machine configuration is low, reduce file cache and memory cache.
  • It is recommended to add the --allow-other parameter; otherwise, some programs may not be readable (permission issues).

Rclone can turn a small VPS into a powerful server, but parameters must be configured reasonably to achieve optimal performance. Do not blindly copy and paste parameters from the internet, or the results may not be ideal.

The above is my personal Rclone configuration summary, which does not represent the best configuration and is for reference only. If there are any deficiencies or errors, please leave a message for correction.

Rclone Official Website: https://rclone.org/