[CENTOS] Mounting Aliyun OSS to VPS Server using ossfs
Prepare a Bucket for mounting and configure the permissions.
Obtain the access key and secret key that can be used for mounting the Bucket.
Download and install the ossfs package.
- Install locally.
sudo yum localinstall ossfs_1.80.6_centos7.0_x86_64.rpm
- Configure access by storing the Bucket name, AccessKeyId, and AccessKeySecret with access permissions for this Bucket in the /etc/passwd-ossfs file. Make sure to set the correct permissions for this file, it is recommended to set it as 640.
echo my-bucket:my-access-key-id > /etc/passwd-ossfs
chmod 640 /etc/passwd-ossfs
- Mount the Bucket to the specified directory.
ossfs my-bucket my-mount-point -ourl=my-oss-endpoint
777 permission mode, can be used by non-root users
ossfs my-bucket my-mount-point -ourl=my-oss-endpoint -o allow_other
- Unmount the mounted Bucket.
fusermount -u my-mount-point
- If you want to support writing and control file permissions, the user must have full control permissions for the Bucket, otherwise the permission configuration will be lost after the next mount.
- If used as a remote hard drive and allowing non-root users and other users to read and write, you need to add -o allow_other.
- Uploading large files will result in fragmented storage in the OSS Bucket, so it is recommended to minimize the transfer of large files as there will still be latency even with a fast internal network.
- Streaming or low-level disk read/write operations can freeze the OSS, such as the dd command, as it is not a real hard drive.
- ossfs scans the contents of files in OSS, so if there are many files, it is best to avoid operations like ls and find.
- It is not recommended to use the fstab method for startup, as it may prevent your VPS from restarting.