ossfs is a tool that allows you to mount an OSS bucket to a local Linux system. Your applications can access objects in OSS by using standard file system operations, such as open and read. ossfs automatically translates these operations into OSS API calls.
ossfs is available in two versions: 1.0 and 2.0. Version 2.0 has been completely re-architected for modern, compute-intensive applications. It offers significant performance upgrades but imposes some restrictions on POSIX semantics. It is the primary version for future development. We strongly recommend using ossfs 2.0 for new applications such as AI training, inference, and autonomous driving simulations, especially if you cannot easily use an OSS SDK or use the OSS Connector for AI/ML to accelerate model training. In contrast, ossfs 1.0 provides more comprehensive support for POSIX semantics and is suitable for daily use in less performance-sensitive scenarios.
Prerequisites
-
You have registered an Alibaba Cloud account.
-
You have activated OSS and created a bucket.
Operating environment
ossfs 2.0 is based on Filesystem in Userspace (FUSE).
|
Architecture |
Operating system |
Version |
|
x86_64 |
CentOS |
CentOS 7, CentOS 8 |
|
Rocky Linux |
Rocky Linux 9.0 and later |
|
|
Alibaba Cloud Linux |
Alibaba Cloud Linux 2 and later |
|
|
Ubuntu |
Ubuntu 20.04 LTS and later LTS versions |
|
|
Debian |
Debian 11 and later |
|
|
aarch64 |
Alibaba Cloud Linux |
Alibaba Cloud Linux 3 |
Install ossfs 2.0
Alibaba Cloud Linux
-
Download the package for your system architecture.
-
x86_64 architecture:
sudo wget https://gosspublic.alicdn.com/ossfs/ossfs2_2.0.7_linux_x86_64.rpm -
aarch64 architecture:
sudo wget https://gosspublic.alicdn.com/ossfs/ossfs2_2.0.7_linux_aarch64.rpm
-
-
Install ossfs 2.0 for your system architecture.
-
x86_64 architecture:
sudo yum install ossfs2_2.0.7_linux_x86_64.rpm -y -
aarch64 architecture:
sudo yum install ossfs2_2.0.7_linux_aarch64.rpm -y
-
-
Verify the installation.
ossfs2 --versionNoteossfs2 is installed at
/usr/local/bin/ossfs2. If yourPATHis customized, use the absolute path/usr/local/bin/ossfs2to run ossfs2.
CentOS/Rocky Linux
-
Download the package.
sudo wget https://gosspublic.alicdn.com/ossfs/ossfs2_2.0.7_linux_x86_64.rpm -
Install ossfs 2.0.
sudo yum install ossfs2_2.0.7_linux_x86_64.rpm -y -
Verify the installation.
ossfs2 --versionNoteossfs2 is installed at
/usr/local/bin/ossfs2. If yourPATHis customized, use the absolute path/usr/local/bin/ossfs2to run ossfs2.
Ubuntu
-
Download the package.
sudo wget https://gosspublic.alicdn.com/ossfs/ossfs2_2.0.7_linux_x86_64.deb -
Install ossfs 2.0.
sudo dpkg -i ossfs2_2.0.7_linux_x86_64.deb -
Verify the installation.
ossfs2 --versionNoteossfs2 is installed at
/usr/local/bin/ossfs2. If yourPATHis customized, use the absolute path/usr/local/bin/ossfs2to run ossfs2.
Configure ossfs 2.0
To mount an OSS bucket, you must create a configuration file specific to your scenario. You can then reference this file when you run the mount command.
-
Create an AccessKey pair for a RAM user that has OSS management permissions.
-
Set your OSS credentials as environment variables.
export OSS_ACCESS_KEY_ID=LTAI****************** export OSS_ACCESS_KEY_SECRET=8CE4********************** -
You can use any name and path for the ossfs 2.0 configuration file. For example, create a file named
/etc/ossfs2.conf.sudo touch /etc/ossfs2.conf -
Enter the mount information. The following example shows a configuration for mounting an entire bucket in read-only mode.
NoteTo view the endpoint of a bucket, go to the Buckets page, select the target bucket, and then click Overview in the left-side navigation pane. The endpoint is displayed in the Port section. The following examples use a bucket in the China (Hangzhou) region.
The endpoints for a bucket in the China (Hangzhou) region are as follows: The public endpoint is
oss-cn-hangzhou.aliyuncs.com. The internal endpoint for access from an Elastic Compute Service (ECS) instance in the classic network or a Virtual Private Cloud (VPC) isoss-cn-hangzhou-internal.aliyuncs.com. The transfer acceleration endpoint for global uploads and downloads isoss-accelerate.aliyuncs.com. The OSS accelerator endpoint iscn-hangzhou-internal.oss-data-acc.aliyuncs.com. All endpoints support HTTPS.Open the ossfs 2.0 configuration file that you created. Configure and save the file based on the following example, which uses an internal endpoint in the China (Hangzhou) region. For faster and more stable data transmission, use an internal endpoint or an OSS accelerator endpoint to mount a bucket from an instance that is in a VPC in the same region. We do not recommend using a public endpoint to access ossfs. High latency and unstable internet connections can cause performance issues.
# The endpoint of the region where the bucket is located --oss_endpoint=https://oss-cn-hangzhou-internal.aliyuncs.com # The name of the bucket --oss_bucket=bucketName # Mount in read-only mode --ro=true
Mount and access the bucket
-
Create a mount point.
You can create the mount point with any name and at any path. For this example, create the
/tmp/ossfs2-bucketdirectory.sudo mkdir /tmp/ossfs2-bucket -
Run the command to mount the bucket.
The following command mounts the bucket specified in the
ossfs2.confconfiguration file to the local/tmp/ossfs2-bucket/directory in read-only mode. To mount the bucket in read/write mode, remove the--ro=trueoption from theossfs2.conffile.sudo ossfs2 mount /tmp/ossfs2-bucket/ -c /etc/ossfs2.conf -
Access the mounted bucket.
After the bucket is mounted, you can access the objects in it as if they were local files. For example, run the
sudo ls -lh /tmp/ossfs2-bucket/command to list the files in the mounted bucket.[root@hostname ~]# sudo ls -lh /tmp/ossfs2-bucket/ total 36G drwxrwxrwx 1 root root 0 Mar 20 13:27 100G drwxrwxrwx 1 root root 0 Mar 20 13:27 100G -rwxrwxrwx 1 root root 36G Feb 21 10:48 xxx.bin drwxrwxrwx 1 root root 0 Mar 20 10:48 checkpoints -rwxrwxrwx 1 root root 0 Feb 10 18:25 filename.txt -rwxrwxrwx 1 root root 23K Mar 7 13:26 xxx.txt -rwxrwxrwx 1 root root 191 Feb 25 15:10 xxx.txt drwxrwxrwx 1 root root 0 Mar 20 10:48 img -rwxrwxrwx 1 root root 575 Mar 6 16:52 xxx.txt -rwxrwxrwx 1 root root 269 Jan 23 14:48 xxx.txt -rwxrwxrwx 1 root root 2.2M Feb 10 13:20 xxx.txt -rwxrwxrwx 1 root root 11 Jan 23 14:08 xxxon.txt -rwxrwxrwx 1 root root 2.1K Jan 24 14:16 xxx.txt -rwxrwxrwx 1 root root 2.1K Jan 24 14:17 xxx.txt -rwxrwxrwx 1 root root 4.8K Feb 10 13:36 xxx.txt -rwxrwxrwx 1 root root 2.1K Jan 23 17:52 xxx -
Unmount the bucket.
If you no longer need the mounted bucket, run the following command to unmount it.
sudo umount /tmp/ossfs2-bucket/