[GH-ISSUE #623] Can I mount a folder within a bucket instead of the root bucket? #355

Closed
opened 2026-03-04 01:44:41 +03:00 by kerem · 19 comments
Owner

Originally created by @quadgnim on GitHub (Jul 19, 2017).
Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/623

Hi all, I'm successfully mounting a bucket and through it I have access to all my files and folders. However, in some cases I just want to mount the folder and not provide the client access to everything else in the bucket. Creating separate buckets is less ideal than placing things into folders and mounting a specific folder. However, I can't seem to figure out a way to do this?

Current mount command using fstab =

3fs#quadgnimsbucket /tmp/s3_mount fuse _netdev,iam_role=auto,url=https://s3.amazonaws.com,use_cache=/tmp,allow_other,nonempty,use_sse,endpoint=us-east-1

Within quadgnimsbucket is a folder called mytestfolder

Any tricks on how to mount the specific folder?

Additional Information

The following information is very important in order to help us to help you. Omission of the following details may delay your support request or receive no attention at all.

  • Version of s3fs being used (s3fs --version)
    V1.82

  • Version of fuse being used (pkg-config --modversion fuse)
    2.9.7

  • System information (uname -a)
    2.6.32-696.3.2.el6.x86_64

Originally created by @quadgnim on GitHub (Jul 19, 2017). Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/623 Hi all, I'm successfully mounting a bucket and through it I have access to all my files and folders. However, in some cases I just want to mount the folder and not provide the client access to everything else in the bucket. Creating separate buckets is less ideal than placing things into folders and mounting a specific folder. However, I can't seem to figure out a way to do this? Current mount command using fstab = 3fs#quadgnimsbucket /tmp/s3_mount fuse _netdev,iam_role=auto,url=https://s3.amazonaws.com,use_cache=/tmp,allow_other,nonempty,use_sse,endpoint=us-east-1 Within quadgnimsbucket is a folder called mytestfolder Any tricks on how to mount the specific folder? #### Additional Information _The following information is very important in order to help us to help you. Omission of the following details may delay your support request or receive no attention at all._ - Version of s3fs being used (s3fs --version) V1.82 - Version of fuse being used (pkg-config --modversion fuse) 2.9.7 - System information (uname -a) 2.6.32-696.3.2.el6.x86_64
kerem closed this issue 2026-03-04 01:44:41 +03:00
Author
Owner
<!-- gh-comment-id:317188155 --> @gaul commented on GitHub (Jul 22, 2017): https://github.com/s3fs-fuse/s3fs-fuse/wiki/Fuse-Over-Amazon#prefix-default-coming-soon
Author
Owner

@tzahimizrahi commented on GitHub (Sep 24, 2017):

@quadgnim did you manage to to mount s3 folder?
I am also curious about it

<!-- gh-comment-id:331728974 --> @tzahimizrahi commented on GitHub (Sep 24, 2017): @quadgnim did you manage to to mount s3 folder? I am also curious about it
Author
Owner

@quadgnim commented on GitHub (Sep 24, 2017):

Yes, use the format

S3fs#bucket:/folder if memory serves

Maybe two slashes //

Thanks,

Larry

On Sep 24, 2017 2:22 PM, "tzahimizrahi" notifications@github.com wrote:

@quadgnim https://github.com/quadgnim did you manage to to mount s3
folder?
I am also curious about it


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/s3fs-fuse/s3fs-fuse/issues/623#issuecomment-331728974,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AEdtKLrbE-z3FvBs5kNAEEkr_ffWaNV7ks5slp3UgaJpZM4OdDn8
.

<!-- gh-comment-id:331740823 --> @quadgnim commented on GitHub (Sep 24, 2017): Yes, use the format S3fs#bucket:/folder if memory serves Maybe two slashes // Thanks, Larry On Sep 24, 2017 2:22 PM, "tzahimizrahi" <notifications@github.com> wrote: > @quadgnim <https://github.com/quadgnim> did you manage to to mount s3 > folder? > I am also curious about it > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > <https://github.com/s3fs-fuse/s3fs-fuse/issues/623#issuecomment-331728974>, > or mute the thread > <https://github.com/notifications/unsubscribe-auth/AEdtKLrbE-z3FvBs5kNAEEkr_ffWaNV7ks5slp3UgaJpZM4OdDn8> > . >
Author
Owner

@shivkaundal commented on GitHub (Aug 23, 2018):

Hello,

is this issue closed?

<!-- gh-comment-id:415471566 --> @shivkaundal commented on GitHub (Aug 23, 2018): Hello, is this issue closed?
Author
Owner

@darthvadrismydad commented on GitHub (Oct 8, 2018):

This doesn't work for me. when I mount a sub-folder within a bucket, I get:

[CRT] s3fs.cpp:s3fs_check_service(3784): bucket not found(host=https://s3.amazonaws.com) - result of checking service.

When I just mount the bucket, the mounting works but I cannot view anything within the sub-folders. I just get a 'Operation not permitted':

ls: cannot open directory my-bucket/data: Operation not permitted

EDIT: System Data

OS: CentoOS (Amazon Linux)
Installation Method: Clone Git & Run Make
SSE/KMS Used: Yes (managed key)
IAM Role: Set to "auto"

<!-- gh-comment-id:427949357 --> @darthvadrismydad commented on GitHub (Oct 8, 2018): This doesn't work for me. when I mount a sub-folder within a bucket, I get: `[CRT] s3fs.cpp:s3fs_check_service(3784): bucket not found(host=https://s3.amazonaws.com) - result of checking service.` When I just mount the bucket, the mounting works but I cannot view anything within the sub-folders. I just get a 'Operation not permitted': `ls: cannot open directory my-bucket/data: Operation not permitted` EDIT: System Data OS: CentoOS (Amazon Linux) Installation Method: Clone Git & Run Make SSE/KMS Used: Yes (managed key) IAM Role: Set to "auto"
Author
Owner

@haghabozorgi commented on GitHub (Oct 11, 2018):

@InspiredIdealist it only seems to work with dirs that were created by fuse. so if you mount a bucket, create a 'dir' (e.g myfusedir) inside that bucket then umount bucket and remount that (myfusedir) dir you created it works.
If you create the dir outside of fuse (e.g aws cli) and try to mount it, it does not seem to work. I think it is related to https://github.com/s3fs-fuse/s3fs-fuse/wiki/FAQ#q-could-not-access-filesdirectories-by-permission-denied.

I am trying to confirm and find a solution. I believe the solution might be to run https://github.com/s3fs-fuse/s3fs-fuse/blob/master/test/mergedir.sh but have not tested yet.

<!-- gh-comment-id:429053362 --> @haghabozorgi commented on GitHub (Oct 11, 2018): @InspiredIdealist it only seems to work with dirs that were created by fuse. so if you mount a bucket, create a 'dir' (e.g myfusedir) inside that bucket then umount bucket and remount that (myfusedir) dir you created it works. If you create the dir outside of fuse (e.g aws cli) and try to mount it, it does not seem to work. I think it is related to https://github.com/s3fs-fuse/s3fs-fuse/wiki/FAQ#q-could-not-access-filesdirectories-by-permission-denied. I am trying to confirm and find a solution. ~~I believe the solution might be to run https://github.com/s3fs-fuse/s3fs-fuse/blob/master/test/mergedir.sh but have not tested yet.~~
Author
Owner

@darthvadrismydad commented on GitHub (Oct 14, 2018):

Ah ok, understood. So as a workaround, I just have to make sure we apply those metadata tags first to any given file in the sub-directory of choice within a given bucket.

<!-- gh-comment-id:429645560 --> @darthvadrismydad commented on GitHub (Oct 14, 2018): Ah ok, understood. So as a workaround, I just have to make sure we apply those metadata tags first to any given file in the sub-directory of choice within a given bucket.
Author
Owner

@haghabozorgi commented on GitHub (Oct 15, 2018):

@InspiredIdealist thats what it seems like but I was not able to get it working. So far if i create a "folder" in s3 bucket using aws management console mounting to folder works as expected, if i use aws cli or terraform for example, to create the "folder", it does not seem to work, even if i then go and add the metadata tags. Let me know if you have any luck.

<!-- gh-comment-id:429922264 --> @haghabozorgi commented on GitHub (Oct 15, 2018): @InspiredIdealist thats what it seems like but I was not able to get it working. So far if i create a "folder" in s3 bucket using aws management console mounting to folder works as expected, if i use aws cli or terraform for example, to create the "folder", it does not seem to work, even if i then go and add the metadata tags. Let me know if you have any luck.
Author
Owner

@darthvadrismydad commented on GitHub (Oct 23, 2018):

Hmm that is strange, I haven't had a chance to try the metadata tags out. I will report back when I have a chance to try it out.

<!-- gh-comment-id:432328242 --> @darthvadrismydad commented on GitHub (Oct 23, 2018): Hmm that is strange, I haven't had a chance to try the metadata tags out. I will report back when I have a chance to try it out.
Author
Owner

@APAC-DevOps commented on GitHub (Feb 25, 2019):

@InspiredIdealist thats what it seems like but I was not able to get it working. So far if i create a "folder" in s3 bucket using aws management console mounting to folder works as expected, if i use aws cli or terraform for example, to create the "folder", it does not seem to work, even if i then go and add the metadata tags. Let me know if you have any luck.

Thanks for the sharing.
I encountered a similar issue on my end as well.
I have an AWS SFTP, if I created SFTP User with optional home dir, and logged in to my AWS SFTP with that SFTP user, then, sub-folder would be created automatically under the designated S3 bucket.
however, when I tried to mount to that directory from my EC2 instance, it could not get through.
I had to manually create folder for my SFTP user from AWS S3 console, then, do dir mounting from my EC2 instance.

This seems to be a bug in AWS. Did you ever get any update from AWS about this issue?

<!-- gh-comment-id:466839485 --> @APAC-DevOps commented on GitHub (Feb 25, 2019): > @InspiredIdealist thats what it seems like but I was not able to get it working. So far if i create a "folder" in s3 bucket using aws management console mounting to folder works as expected, if i use aws cli or terraform for example, to create the "folder", it does not seem to work, even if i then go and add the metadata tags. Let me know if you have any luck. Thanks for the sharing. I encountered a similar issue on my end as well. I have an AWS SFTP, if I created SFTP User with optional home dir, and logged in to my AWS SFTP with that SFTP user, then, sub-folder would be created automatically under the designated S3 bucket. however, when I tried to mount to that directory from my EC2 instance, it could not get through. I had to manually create folder for my SFTP user from AWS S3 console, then, do dir mounting from my EC2 instance. This seems to be a bug in AWS. Did you ever get any update from AWS about this issue?
Author
Owner

@ggtakec commented on GitHub (Mar 29, 2019):

We kept this issue open for a long time.

The problem is that the path is not a directory object s3fs can recognize.
You need to specify a path that s3fs can recognize as a directory.
In order for s3fs to recognize an object (path) as a directory, you can create a directory using s3fs or update the information in the directory.

I added about this issue to wiki page:
https://github.com/s3fs-fuse/s3fs-fuse/wiki/FAQ#q-could-not-mount-with-specifying-the-path-under-bucket

I will close this, but if the problem persists, please reopen or post a new issue.
Thanks in advance for your assistance.

<!-- gh-comment-id:477851368 --> @ggtakec commented on GitHub (Mar 29, 2019): We kept this issue open for a long time. The problem is that the path is not a directory object s3fs can recognize. You need to specify a path that s3fs can recognize as a directory. In order for s3fs to recognize an object (path) as a directory, you can create a directory using s3fs or update the information in the directory. I added about this issue to wiki page: https://github.com/s3fs-fuse/s3fs-fuse/wiki/FAQ#q-could-not-mount-with-specifying-the-path-under-bucket I will close this, but if the problem persists, please reopen or post a new issue. Thanks in advance for your assistance.
Author
Owner

@APAC-DevOps commented on GitHub (Mar 29, 2019):

We kept this issue open for a long time.

The problem is that the path is not a directory object s3fs can recognize.
You need to specify a path that s3fs can recognize as a directory.
In order for s3fs to recognize an object (path) as a directory, you can create a directory using s3fs or update the information in the directory.

I added about this issue to wiki page:
https://github.com/s3fs-fuse/s3fs-fuse/wiki/FAQ#q-could-not-mount-with-specifying-the-path-under-bucket

I will close this, but if the problem persists, please reopen or post a new issue.
Thanks in advance for your assistance.

may be you might want to tell users in public community that "folder" object created via AWS web GUI does not have this issue. This seems to be easier than the mounting-and-remounting method mentioned in the link above.

<!-- gh-comment-id:477929688 --> @APAC-DevOps commented on GitHub (Mar 29, 2019): > We kept this issue open for a long time. > > The problem is that the path is not a directory object s3fs can recognize. > You need to specify a path that s3fs can recognize as a directory. > In order for s3fs to recognize an object (path) as a directory, you can create a directory using s3fs or update the information in the directory. > > I added about this issue to wiki page: > https://github.com/s3fs-fuse/s3fs-fuse/wiki/FAQ#q-could-not-mount-with-specifying-the-path-under-bucket > > I will close this, but if the problem persists, please reopen or post a new issue. > Thanks in advance for your assistance. may be you might want to tell users in public community that "folder" object created via AWS web GUI does not have this issue. This seems to be easier than the mounting-and-remounting method mentioned in the link above.
Author
Owner

@Wang-Kai commented on GitHub (May 15, 2020):

Yes, use the format S3fs#bucket:/folder if memory serves Maybe two slashes // Thanks, Larry

On Sep 24, 2017 2:22 PM, "tzahimizrahi" @.***> wrote: @quadgnim https://github.com/quadgnim did you manage to to mount s3 folder? I am also curious about it — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <#623 (comment)>, or mute the thread https://github.com/notifications/unsubscribe-auth/AEdtKLrbE-z3FvBs5kNAEEkr_ffWaNV7ks5slp3UgaJpZM4OdDn8 .

It is not workable with minio .

<!-- gh-comment-id:629178859 --> @Wang-Kai commented on GitHub (May 15, 2020): > Yes, use the format S3fs#bucket:/folder if memory serves Maybe two slashes // Thanks, Larry > […](#) > On Sep 24, 2017 2:22 PM, "tzahimizrahi" ***@***.***> wrote: @quadgnim <https://github.com/quadgnim> did you manage to to mount s3 folder? I am also curious about it — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <[#623 (comment)](https://github.com/s3fs-fuse/s3fs-fuse/issues/623#issuecomment-331728974)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AEdtKLrbE-z3FvBs5kNAEEkr_ffWaNV7ks5slp3UgaJpZM4OdDn8> . It is not workable with minio .
Author
Owner

@sgandon commented on GitHub (Aug 7, 2020):

@Wang-Kai , It works fine with minio, I am using mybucket:/subfolder in the s3fs command.
You have to make sure the folder is not empty otherwise the mount succedes but no file can be added or read to/from the mount.

<!-- gh-comment-id:670561450 --> @sgandon commented on GitHub (Aug 7, 2020): @Wang-Kai , It works fine with minio, I am using `mybucket:/subfolder` in the s3fs command. You have to make sure the folder is not empty otherwise the mount succedes but no file can be added or read to/from the mount.
Author
Owner

@nikiladonya commented on GitHub (Aug 19, 2020):

@sgandon do you use standalone or distributed minio configuration?

<!-- gh-comment-id:676537581 --> @nikiladonya commented on GitHub (Aug 19, 2020): @sgandon do you use standalone or distributed minio configuration?
Author
Owner

@jonassvatos commented on GitHub (Aug 30, 2020):

I can confirm that mounting subdir doesn't work against standalone MINIO.RELEASE.2020-08-27T05-16-20Z

s3fs log:
aug 30 00:00:00 localhost s3fs[8905]: s3fs.cpp:s3fs_check_service(3780): bucket not found(host=http://localhost:9000) - result of checking service.

/etc/fstab entry:
s3fs#bucket:/directory/ /mnt/test-s3fs fuse _netdev,rw,allow_other,noatime,use_path_request_style,uid=1000,gid=1000,umask=0002,passwd_file=/etc/s3cred,multipart_size=5,url=http://localhost:9000/ 0 0

MINIO trace log shows:
00:00:00.000 [404 Not Found] s3.GetObject localhost:9000/bucket/directory/ localhost 1.714ms ↑ 84 B ↓ 592 B

<!-- gh-comment-id:683425410 --> @jonassvatos commented on GitHub (Aug 30, 2020): I can confirm that mounting subdir doesn't work against standalone MINIO.RELEASE.2020-08-27T05-16-20Z s3fs log: aug 30 00:00:00 localhost s3fs[8905]: s3fs.cpp:s3fs_check_service(3780): bucket not found(host=http://localhost:9000) - result of checking service. /etc/fstab entry: s3fs#bucket:/directory/ /mnt/test-s3fs fuse _netdev,rw,allow_other,noatime,use_path_request_style,uid=1000,gid=1000,umask=0002,passwd_file=/etc/s3cred,multipart_size=5,url=http://localhost:9000/ 0 0 MINIO trace log shows: 00:00:00.000 [404 Not Found] s3.GetObject localhost:9000/bucket/directory/ localhost 1.714ms ↑ 84 B ↓ 592 B
Author
Owner

@sgandon commented on GitHub (Aug 31, 2020):

@nikiladonya I was using the standalone version.

<!-- gh-comment-id:683635706 --> @sgandon commented on GitHub (Aug 31, 2020): @nikiladonya I was using the standalone version.
Author
Owner

@dvaldivia commented on GitHub (Apr 5, 2021):

seems to not be working with MinIO because s3fs tries to perform a GetObject operation on the subpath, for example with bucket influxdb and subpath :/pod-0 I see the 404 that @InspiredIdealist reported

from mc admin trace

22:46:02.113 [404 Not Found] s3.GetObject minio.ns-1.svc.cluster.local/influxdb/pod-0/ 10.244.2.8        2.519ms      ↑ 84 B ↓ 535 B
22:46:03.613 [404 Not Found] s3.GetObject minio.ns-1.svc.cluster.local/influxdb/pod-0/ 10.244.2.8        9.869ms      ↑ 84 B ↓ 535 B

Is there an expected response from the S3 store the s3fs is looking for specifically? even if the sub-folder exists on my MinIO setup, the getObject will fail every time

<!-- gh-comment-id:813693895 --> @dvaldivia commented on GitHub (Apr 5, 2021): seems to not be working with MinIO because `s3fs` tries to perform a `GetObject` operation on the subpath, for example with bucket `influxdb` and subpath `:/pod-0` I see the 404 that @InspiredIdealist reported from `mc admin trace` ``` 22:46:02.113 [404 Not Found] s3.GetObject minio.ns-1.svc.cluster.local/influxdb/pod-0/ 10.244.2.8 2.519ms ↑ 84 B ↓ 535 B 22:46:03.613 [404 Not Found] s3.GetObject minio.ns-1.svc.cluster.local/influxdb/pod-0/ 10.244.2.8 9.869ms ↑ 84 B ↓ 535 B ``` Is there an expected response from the S3 store the `s3fs` is looking for specifically? even if the sub-folder exists on my MinIO setup, the getObject will fail every time
Author
Owner

@dvaldivia commented on GitHub (Apr 5, 2021):

I think probing the prefix via ListObjectsV2 might be a better solution to probe access to the desired "folder"

<!-- gh-comment-id:813704753 --> @dvaldivia commented on GitHub (Apr 5, 2021): I think probing the prefix via `ListObjectsV2` might be a better solution to probe access to the desired "folder"
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/s3fs-fuse#355
No description provided.