Chatting about the matters of Rclone mounting

Publish: 2020-12-27 | Modify: 2020-12-27

Rclone is a command-line program that supports multiple systems such as Windows, Linux, and MacOS. It can mount more than 40 types of network storage and is a rare mounting tool. This article will discuss some instructions and precautions for Rclone.

Rclone Logo

Installing Rclone

This article takes CentOS 7 as an example, and all the following commands are executed on CentOS 7. Rclone is developed using Golang, and the official binary package has been compiled, so the installation is very simple. Just execute the following command:

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

If it is a production or important environment, it is recommended to create a separate user to run Rclone. This article does not provide detailed instructions on this. After the installation is complete, 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

Our usual practice is to install Rclone on a VPS and mount various cloud storage (such as OneDrive). This article does not provide instructions on configuring storage (assuming you have already added the storage). Rclone mounts cloud storage to the local machine through network mounting. Since it is mounted via the network, the performance and stability are naturally not as good as local disks.

In addition, during use, you may also find that Rclone consumes high CPU and memory. This is related to the performance of the machine itself and the Rclone configuration. If it is for personal use, it is recommended to configure as follows:

  • CPU: 2 cores
  • Memory: 1Gb or more
  • Disk: no less than 30Gb

Mounting Parameters

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

# Install fuse on CentOS 7
yum -y install fuse

Here, I have already mounted the OneDrive storage and named it od, which can be viewed by 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 mounted an additional disk, it is recommended to create a symbolic link for this directory to a non-system disk to avoid excessive use of the system disk by Rclone.

Now, let's explain with 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 scared by the long command above, let's break it down and find that it is actually very simple:

  • rclone mount: the Rclone mount command
  • od:/file: as mentioned above, I have already configured OneDrive and named it od, and 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 it
  • --attr-timeout 5m: file attribute cache time (size, modification time, etc.). If the server 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 the interaction between Rclone and the API and improves file read and write efficiency
  • --vfs-cache-max-age 24h: VFS file cache time, set to 24 hours here. If the files are rarely changed, it is recommended to set a longer time
  • --vfs-cache-max-size 10G: VFS file cache maximum size, recommended not to exceed 50% of the current available disk space
  • --vfs-read-chunk-size-limit 100M: chunk size for reading. Here, it is set to 100M, which improves file reading efficiency. For example, a 1G file is roughly divided into 10 chunks for reading, but at the same time, the number of API requests will also increase
  • --buffer-size 100M: memory cache. If you have less memory, you can reduce this value. If you have more memory, you can increase it appropriately
  • --daemon: runs in the background

After understanding the meanings of the above parameters, you can adjust them according to the configuration of your server to avoid excessive CPU and memory usage by Rclone. For more parameter explanations, please refer to the official documentation: https://rclone.org/commands/rclone_mount/

Unmounting

In general, you can directly 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 it prompts that the disk is busy, you can only forcefully kill the process. The command is:

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

Conclusion

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

Rclone can turn a small VPS into a big server, but it also needs to be configured properly to achieve optimal performance. Remember not to blindly copy and paste parameters from the Internet, as 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 comment.

Rclone official website: https://rclone.org/


Comments