s3fs-fuse 将 Linode Object Storage 挂载到 Ubuntu Server 本地文件系统

更新日期: 2024-06-26 阅读次数: 590 字数: 387 分类: Linux

s3fs 是什么

s3fs 是一个将 Amazon S3 存储桶挂载到本地文件系统的工具,它允许用户通过标准的文件系统接口访问 S3 存储桶中的数据,从而简化了与 S3 的交互过程。

s3fs 通过 FUSE(Filesystem in Userspace)将 S3 存储桶映射为本地文件系统,使得用户可以使用标准的文件系统 API 来与 S3 中的数据进行交互,而无需直接调用 S3 API。

https://github.com/s3fs-fuse/s3fs-fuse

  • s3fs allows Linux, macOS, and FreeBSD to mount an S3 bucket via FUSE.
  • s3fs makes you operate files and directories in S3 bucket like a local file system.
  • s3fs preserves the native object format for files, allowing use of other tools like AWS CLI.

Linode Objects

Object Storage 是全球可用、兼容 S3 的存储解决方案,即便您的数据增长,性能仍然保持不变。

参考:

https://www.linode.com/zh/products/object-storage/

价格:250G,5 刀每月。500GB 的传输费用为 0 美元。相对 AWS S3 和 Google Cloud Storage 省去了传输费用。

Ubuntu 24.04 安装 s3fs

sudo apt install s3fs

/etc/fstab

配置 /etc/fstab 文件 (/etc/fstab 文件中的每一行表示一个挂载点),添加

mybucket /mount/s3 fuse.s3fs _netdev,allow_other,use_path_request_style,url=https://us-east-1.linodeobjects.com/ 0 0

/etc/passwd-s3fs

填写

ACCESS_KEY:SECRET_KEY
chmod 600 /etc/passwd-s3fs

// mount bucket
mount -a

MOUNTPOINT directory is not empty

# mount -a
s3fs: MOUNTPOINT directory /var/www/html/xxx is not empty. if you are sure this is safe, can use the 'nonempty' mount option.
mount: (hint) your fstab has been modified, but systemd still uses
       the old version; use 'systemctl daemon-reload' to reload.

在 /etc/fstab 中增加一个 nonempty 配置

mybucket /mount/s3 fuse.s3fs _netdev,allow_other,use_path_request_style,nonempty,url=https://us-east-1.linodeobjects.com/ 0 0

参考

  • https://www.linode.com/community/questions/18817/how-do-i-use-s3fs-on-linode-object-storage
  • https://www.linode.com/community/questions/21663/how-do-i-mount-a-subdirectory-in-my-object-storage-bucket-using-s3fs

微信关注我哦 👍

大象工具微信公众号

我是来自山东烟台的一名开发者,有敢兴趣的话题,或者软件开发需求,欢迎加微信 zhongwei 聊聊, 查看更多联系方式