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.
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
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
Simply enter umount /home/ossfs
to unmount.
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.
For detailed instructions, please refer to the project address: aliyun/ossfs
I come from China and I am a freelancer. I specialize in Linux operations, PHP, Golang, and front-end development. I have developed open-source projects such as Zdir, ImgURL, CCAA, and OneNav.