Mounting Alibaba Cloud OSS to ECS using OSSFS in CentOS 6

Publish: 2016-09-23 | Modify: 2018-08-17

OSS is an object storage service launched by Alibaba Cloud, similar to Qiniu Cloud Storage, and the price is relatively cheap. Recently, I discovered a tool called OSSFS that can mount OSS to Alibaba Cloud ECS servers, achieving the purpose of storage/backup.

OSSFS Features

  • Supports most of the features of the POSIX file system, including file read/write, directory, link operations, permissions, uid/gid, and extended attributes.
  • Uploads large files through OSS's multipart feature.
  • MD5 checksum ensures data integrity.

Installation

SSH to the server and execute the following commands:

wget https://github.com/aliyun/ossfs/releases/download/v1.79.9/ossfs_1.79.9_centos6.5_x86_64.rpm
sudo yum localinstall ossfs_1.79.9_centos6.5_x86_64.rpm

Running and Examples

Set the bucket name and access key/id information and store them in the /etc/passwd-ossfs file. Note that the permissions of this file must be correctly set, and it is recommended to set it as 640.

echo my-bucket:my-access-key-id:my-access-key-secret > /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs

Mount the OSS bucket to a specified directory.

ossfs my-bucket my-mount-point -ourl=my-oss-endpoint

Here are examples of mounting the bucket named xiaoz, with AccessKeyId faint, AccessKeySecret 123, and oss endpoint http://oss-cn-hangzhou-internal.aliyuncs.com (intranet) to the directory /home/ossfs. Please refer to the OSS Region and Endpoint Comparison Table for the endpoint mapping.

echo xiaoz:faint:123 > /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs
mkdir /home/ossfs
ossfs xiaoz /home/ossfs -ourl=http://oss-cn-hangzhou-internal.aliyuncs.com

Unmounting

Simply enter umount /home/ossfs to unmount.

Summary

OSS can be mounted not only through the intranet but also through the internet. If you have purchased both ECS and OSS in the same region on Alibaba Cloud, you can mount OSS to the intranet for file storage or backup purposes. Below is a screenshot of the OSS mounted on the Xiaoz blog.

2016-09-23_112954

For detailed instructions, please refer to the project address: aliyun/ossfs


Comments