Mounting Alibaba Cloud OSS to CentOS 6 ECS Using OSSFS
OSS is Alibaba Cloud's object storage service, similar to Qiniu Cloud Storage, with affordable pricing. Recently, a tool called OSSFS was discovered that allows mounting OSS to Alibaba Cloud ECS servers, achieving storage and backup goals.
OSSFS Features
- Supports most POSIX filesystem functions, including file read/write, directories, link operations, permissions, uid/gid, and extended attributes.
- Uploads large files via OSS's multipart functionality.
- Ensures data integrity through MD5 checksums.
Installation
SSH into 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, storing them in the /etc/passwd-ossfs file. Note that the file permissions must be set correctly; it is recommended to set them to 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


Below is an example of mounting a bucket named xiaoz in the China East 1 (Hangzhou) region with AccessKeyId faint, AccessKeySecret 123, and the OSS endpoint http://oss-cn-hangzhou-internal.aliyuncs.com (internal network) to the /home/ossfs directory. For the Endpoint reference table, please visit: OSS Region and Endpoint Reference Table.
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 via both internal and public networks. If you have purchased both ECS and OSS in the same region on Alibaba Cloud, mounting OSS via the internal network is ideal for file storage or backup. Below is a screenshot of the mounted directory from Xiaoz's blog.

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