How do I mount a subdirectory in my Object Storage bucket using s3fs?

Linode Staff

I'm using Object Storage, and a tool called s3fs, which makes it possible to mount S3-compatible storage as a normal filesystem in Linux. This works very well when mounting the whole bucket.

However, when I'm trying to mount a "subdirectory" using the syntax $BUCKET_NAME:/$FOLDER_NAME, this does not work. So my question is, is there a way to mount only a single folder contained in one of my Object Storage buckets using the s3fs tool?

1 Reply

I was able to accomplish this using Debian 9 running on a standard Linode plan, with the latest version of s3fs. My Object Storage bucket is set to Private using the ACL dropdown in the bucket details in Linode Cloud Manager. I had several folders created in the bucket, with a few files in each.

  • I first created an empty directory on my Linode to serve as a mount point for the specific bucket subdirectory I'm trying to mount.

  • I created a file, named .passwd-s3fs in my home directory, with my access key credentials in this format:

  • I then set the permissions to owner-only for .passwd-s3fs by running
chmod 600 .passwd-s3fs
  • Finally I mounted my bucket subdirectory to the mount point by running the following command:
s3fs $BUCKET_NAME:/$FOLDER_NAME /PATH/TO/MOUNT/POINT -o passwd_file=/HOME/USER/.passwd-s3fs -o url=https://[cluster-id]

In this example:

$BUCKET_NAME:/$FOLDER_NAME is the name of my bucket and the specific subdirectory I am looking to mount

/PATH/TO/MOUNT/POINT is the empty directory I had created to serve as the mount point

/HOME/USER/.passwd-s3fs is the location of my credentials file

https://[cluster-id] is the location of your cluster, where [cluster-id] = eu-central-1, us-east-1, ap-south-1, depending on the location of your bucket.

After running that last command, my folder mounted correctly to my mount point folder. I then tested it by writing files to the mounted subfolder and verified that they appeared when viewing my bucket in Cloud Manager. Additionally, I added files to the subfolder in Cloud Manager then verified that they appeared correctly in my mounted subfolder on my Linode.

For further reading, I would suggest the s3fs-fuse GitHub page, specifically the section pertaining to using s3fs with non-Amazon S3 implementations. There is also a section below the one in my latter link pertaining to fstab, if you are interested in automatically mounting the folder on each boot.

I encountered a lot of different methods for doing this process while researching, but this was the working solution I settled on. If you have any other suggestions or useful tips, please feel free to share them in response to this!


Please enter an answer

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct