banner
年糕

年糕日记

此站为备份站点,最新文章请访问 oior.net
telegram
email

Mounting cloud storage to Linux using Rclone

Preface#

Rclone is a command-line tool that supports synchronization, uploading, and downloading of data between different object storage and cloud storage. It also has practical features such as offline downloading and server backup through some settings. Rclone has many ways of use, and mounting is one of them.

Friendly reminder: Mounting is not necessary and has many limitations and issues as an experimental feature. After mounting, it cannot be used as a real disk and will use local disk space for file operations, which may cause disk full or VPS freeze issues if used improperly. When searching for "Rclone" on Google, the most related keyword is "mounting", which has misled many beginners to some extent. For stable operations such as uploading, downloading, and synchronization, it is recommended to use Rclone's native command functions. For usage, please refer to the "Advanced Usage Tutorial of Rclone - Common Command Parameters".

Installation and Configuration of Rclone#

The official provides a one-click installation script:

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

After installation, enter the rclone config command to enter the interactive configuration options and follow the prompts to proceed step by step. If you are confused, you can refer to the "Rclone Installation and Configuration Tutorial" to understand the detailed configuration process.

Install fuse#

Fuse needs to be installed for mounting. Choose the installation command according to your system:

# Debian/Ubuntu
apt-get update && apt-get install -y fuse
# CentOS
yum install -y fuse

Mounting Cloud Storage#

Mounting cloud storage can be done manually or automatically at startup, depending on your needs.

Manual Mounting#

# Mounting
rclone mount <remote:remote_path> <local_path> [parameters] --daemon

# Unmounting
fusermount -qzu <local_path>

remote is the name filled in during configuration, remote_path is the folder in the cloud storage, leaving it blank represents the entire cloud storage, and local_path is the local folder on the VPS. parameters can be selected according to your needs by referring to the official documentation. The parentheses should not be included in the actual input, they are only used here for clearer distinction. --daemon is the process daemon parameter, which allows running in the background.

Usage Example#

Enter the command to perform the mounting operation:

rclone mount Onedrive:/ /Onedrive --copy-links --allow-other --allow-non-empty --umask 000 --daemon

Then enter the df -h command to check the mounting status.

root@P3TERX:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            286M     0  286M   0% /dev
tmpfs            60M  7.8M   52M  14% /run
/dev/sda1        99G   25G   71G  26% /
tmpfs           297M   24K  297M   1% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           297M     0  297M   0% /sys/fs/cgroup
Onedrive:       5.0T  216G  4.8T   5% /Onedrive # This is the mounted cloud storage

Unmounting:

fusermount -qzu /Onedrive

Automatic Mounting at Startup#

  • Download and edit the self-startup script
wget -N git.io/rcloned && nano rcloned
  • Modify the content:
NAME="Onedrive" # The name filled in during Rclone configuration
REMOTE=''  # Remote folder, a folder mounted in the cloud storage, leaving it blank represents the entire cloud storage
LOCAL='/Onedrive'  # Mounting address, the local mounting directory on the VPS
  • Set up automatic startup
mv rcloned /etc/init.d/rcloned
chmod +x /etc/init.d/rcloned
update-rc.d -f rcloned defaults # Debian/Ubuntu
chkconfig rcloned on # CentOS
bash /etc/init.d/rcloned start

When you see [INFO] rclone started successfully!, it means it is successful.

Management#

Start mounting bash /etc/init.d/rcloned start

Stop mounting bash /etc/init.d/rcloned stop

Remount bash /etc/init.d/rcloned restart

View logs tail -f /$HOME/.rclone/rcloned.log

Uninstalling Self-startup Mounting#

bash /etc/init.d/rcloned stop
update-rc.d -f rcloned remove # Debian/Ubuntu
chkconfig rcloned off # CentOS
rm -f /etc/init.d/rcloned
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.