debian rclone挂载对象存储本地盘

本文详细介绍了Rclone这款命令行工具的安装、配置及使用,包括如何在Linux上安装Rclone,配置不同的对象存储服务,如S3,以及如何挂载对象存储至本地目录,进行数据同步。此外,还提供了Rclone的常用命令及参数说明,如`rclone sync`、`rclone mount`等,以及如何以systemd服务方式启动Rclone。
摘要由CSDN通过智能技术生成

介绍展开目录

Rclone 是一款的命令行工具,支持在不同对象存储、网盘间同步、上传、下载数据。

安装展开目录

安装 EPEL 源:

yum -y install epel-release

安装一些基本组件和依赖:

yum -y install wget unzip screen fuse fuse-devel

下载 Rclone (amd64) 解压然后进入目录(方法 1):

wget https://downloads.rclone.org/rclone-current-linux-amd64.zip
    unzip rclone-current-linux-amd64.zip
    chmod 0755 ./rclone-*/rclone
    cp ./rclone-*/rclone /usr/bin/
    rm -rf ./rclone-*

下载 Rclone (amd64) 解压然后进入目录(方法 2):

curl -O http://downloads.rclone.org/rclone-current-linux-amd64.zip
    unzip rclone-current-linux-amd64.zip
    cd rclone-*-linux-amd64
    cp rclone /usr/sbin/
    chown root:root /usr/sbin/rclone
    chmod 0755 /usr/sbin/rclone

运行 Rclone 开始配置:

./rclone config

第一步选择 n,然后回车输入一个 name,建议这个 name 设置的简单好记一点,然后直接按提示填写即可。(也可以跳过配置步骤,直接再rclone配置文件目录进行配置:vim ~/.config/rclone/rclone.conf)

首都在线对象存储config如下:

[remote2]
type = s3
provider = Other
env_auth = false
access_key_id = c056b4adfxxxxx
secret_access_key = 0e45067d189xxxx
region = other-v2-signature
endpoint = http://oss-cnbj01.cdsgss.com
acl = private
bucket_acl = private
#chunk_size = 5M
#upload_concurrency = 500
v2_auth = true
force_path_style = true

步骤2:创建本地需要挂载的文件夹

mkdir /home/test3/

步骤3:挂载对象存储桶至本地文件夹

rclone mount remote2:bucket-full /home/test3/ --allow-other --allow-non-empty --vfs-cache-mode writes --transfers=50 --progres

参数说明:

-- transfers=50 最大执行的线程数

-- progres 输出消息

其他参数描述:

--allow-non-empty                              Allow mounting over a non-empty directory. Not supported on Windows.
      --allow-other                            Allow access to other users. Not supported on Windows.
      --allow-root                             Allow access to root user. Not supported on Windows.
      --async-read                             Use asynchronous reads. Not supported on Windows. (default true)
      --attr-timeout duration                  Time for which file/directory attributes are cached. (default 1s)
      --daemon                                 Run mount as a daemon (background mode). Not supported on Windows.
      --daemon-timeout duration                Time limit for rclone to respond to kernel. Not supported on Windows.
      --debug-fuse                             Debug the FUSE internals - needs -v.
      --default-permissions                    Makes kernel enforce access control based on the file mode. Not supported on Windows.
      --dir-cache-time duration                Time to cache directory entries for. (default 5m0s)
      --dir-perms FileMode                     Directory permissions (default 0777)
      --file-perms FileMode                    File permissions (default 0666)
      --fuse-flag stringArray                  Flags or arguments to be passed direct to libfuse/WinFsp. Repeat if required.
      --gid uint32                             Override the gid field set by the filesystem. Not supported on Windows.
  -h, --help                                   help for mount
      --max-read-ahead SizeSuffix              The number of bytes that can be prefetched for sequential reads. Not supported on Windows. (default 128k)
      --network-mode                           Mount as remote network drive, instead of fixed disk drive. Supported on Windows only
      --no-checksum                            Don't compare checksums on up/download.
      --no-modtime                             Don't read/write the modification time (can speed things up).
      --no-seek                                Don't allow seeking in files.
      --noappledouble                          Ignore Apple Double (._) and .DS_Store files. Supported on OSX only. (default true)
      --noapplexattr                           Ignore all "com.apple.*" extended attributes. Supported on OSX only.
  -o, --option stringArray                     Option for libfuse/WinFsp. Repeat if required.
      --poll-interval duration                 Time to wait between polling for changes. Must be smaller than dir-cache-time. Only on supported remotes. Set to 0 to disable. (default 1m0s)
      --read-only                              Mount read-only.
      --uid uint32                             Override the uid field set by the filesystem. Not supported on Windows.
      --umask int                              Override the permission bits set by the filesystem. Not supported on Windows.
      --vfs-cache-max-age duration             Max age of objects in the cache. (default 1h0m0s)
      --vfs-cache-max-size SizeSuffix          Max total size of objects in the cache. (default off)
      --vfs-cache-mode CacheMode               Cache mode off|minimal|writes|full (default off)
      --vfs-cache-poll-interval duration       Interval to poll the cache for stale objects. (default 1m0s)
      --vfs-case-insensitive                   If a file name not found, find a case insensitive match.
      --vfs-read-ahead SizeSuffix              Extra read ahead over --buffer-size when using cache-mode full.
      --vfs-read-chunk-size SizeSuffix         Read the source objects in chunks. (default 128M)
      --vfs-read-chunk-size-limit SizeSuffix   If greater than --vfs-read-chunk-size, double the chunk size after each chunk read, until the limit is reached. 'off' is unlimited. (default off)
      --vfs-read-wait duration                 Time to wait for in-sequence read before seeking. (default 20ms)
      --vfs-used-is-size rclone size           Use the rclone size algorithm for Used size.
      --vfs-write-back duration                Time to writeback files after last use when using cache. (default 5s)
      --vfs-write-wait duration                Time to wait for in-sequence write before giving error. (default 1s)
      --volname string                         Set the volume name. Supported on Windows and OSX only.
      --write-back-cache                       Makes kernel buffer writes before sending them to rclone. Without this, writethrough caching is used. Not supported on Windows.

步骤4:查看文件是否挂载成功

df -h

验证测试:
 

vim /home/test.txt

cp /home/test.txt /home/test3/
其他常用命令:
rclone size remote2:bucket-full/test //查看文件夹数量及大小
rclone ls remote2:bucket-full/test //查看文件夹目录
rclone copyto /home/test3 remote2:bucket-full/test --transfers=50 --progres //上传本地文件夹至对象存储桶文件夹

以systemctl服务方式启动:

1,新建一个 rclone.service 文件:

vi /usr/lib/systemd/system/rclone.service

2,写入以下内容

[Unit]
    Description=rclone
        
    [Service]
    User=root
    ExecStart=/usr/bin/rclone rclone mount remote2:bucket-full /home/test3/ --allow-other --allow-non-empty --vfs-cache-mode writes --transfers=50 --progress
    Restart=on-abort
        
    [Install]
    WantedBy=multi-user.target

重载 daemon,让新的服务文件生效:

systemctl daemon-reload
现在就可以用 systemctl来启动 rclone了:
systemctl start rclone

设置开机启动项:

 systemctl enable rclone

停止、查看状态可以用:

操作命令展开目录

rclone 命令的语法格式

Syntax: [options] subcommand <parameters> <parameters...>

常用的 rclone 命令有:

rclone config - 以控制会话的形式添加rclone的配置,配置保存在.rclone.conf文件中。
    rclone copy - 将文件从源复制到目的地址,跳过已复制完成的。
    rclone sync - 将源数据同步到目的地址,只更新目的地址的数据。
    rclone move - 将源数据移动到目的地址。
    rclone delete - 删除指定路径下的文件内容。
    rclone purge - 清空指定路径下所有文件数据。
    rclone mkdir - 创建一个新目录。
    rclone rmdir - 删除空目录。
    rclone check - 检查源和目的地址数据是否匹配。
    rclone ls - 列出指定路径下所有的文件以及文件大小和路径。
    rclone lsd - 列出指定路径下所有的目录/容器/桶。
    rclone lsl - 列出指定路径下所有文件以及修改时间、文件大小和路径。
    rclone md5sum - 为指定路径下的所有文件产生一个md5sum文件。
    rclone sha1sum - 为指定路径下的所有文件产生一个sha1sum文件。
    rclone size - 获取指定路径下,文件内容的总大小。.
    rclone version - 查看当前版本。
    rclone cleanup - 清空remote。
    rclone dedupe - 交互式查找重复文件,进行删除/重命名操作

rclone config展开目录

开启一个交互式的配置会话。命令格式如下:

 rclone config

rclone copy

将文件从源复制到目的地址,跳过已复制完成的。命令格式如下:

 rclone copy source:sourcepath dest:destpsth

rclone sync

  • 同步数据时,可能会删除目的地址的数据;建议先使用–dry-run 标志来检查要复制、删除的数据。

  • 同步数据出错时,不会删除任何目的地址的数据。

  • rclone sync 同步的始终是 path 目录下的数据,而不是 path 目录。(空目录将不会被同步)

  • rclone sync source:path dest:path

    rclone delete展开目录

    删除指定目录的内容。命令格式如下:

  • rclone delete remote:path

  • 更多 rclone 命令,详见 Commands 。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在Debian 10.6上实现开机自动挂载NTFS硬盘,您可以按照以下步骤操作: 1. 确保已经安装了NTFS-3G软件包,该软件包允许您在Linux系统上读写NTFS文件系统。如果您还没有安装,可以使用以下命令安装它: ``` sudo apt update sudo apt install ntfs-3g ``` 2. 找出您要自动挂载的NTFS硬盘的设备名称。您可以使用以下命令列出所有已连接的硬盘: ``` sudo fdisk -l ``` 在输出中找到您要挂载的硬盘,通常以 `/dev/sdX` 形式表示(例如 `/dev/sdb1`)。 3. 创建一个用于挂载硬盘的目录。可以选择任意目录名称,例如 `/media/ntfs`: ``` sudo mkdir /media/ntfs ``` 4. 编辑 `/etc/fstab` 文件以添加挂载条目。使用以下命令打开该文件: ``` sudo nano /etc/fstab ``` 5. 在文件的末尾添加一行,指定要挂载的设备、挂载点和其他选项。例如,如果要挂载 `/dev/sdb1` 到 `/media/ntfs` 目录,并使用默认的挂载选项,可以添加以下行: ``` /dev/sdb1 /media/ntfs ntfs-3g defaults 0 0 ``` 注意:如果您的NTFS硬盘有其他特殊选项或需要特定的权限设置,可以相应地调整这个行。 6. 保存并关闭 `/etc/fstab` 文件(在nano编辑器中,按下 `Ctrl + X`,然后按下 `Y` 以保存更改)。 7. 现在,重新启动您的系统。当系统重新启动时,NTFS硬盘应该会自动挂载到指定的挂载点(`/media/ntfs`)。 请注意,挂载NTFS硬盘时,确保硬盘设备是正确的,并且目标挂载点是有效的。错误的操作可能导致数据丢失或系统问题。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值