[GH-ISSUE #2080] How I made s3fs work #1053

Closed
opened 2026-03-04 01:50:58 +03:00 by kerem · 2 comments
Owner

Originally created by @Qlub53 on GitHub (Dec 21, 2022).
Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/2080

This is to share how I managed to mount my S3 bucket to an AWS EC2 instance. Hopefully it'll help people new to s3fs as well as those who are still struggling.

  1. Create a my-s3-bucket on AWS S3.
  2. Create a new IAM User, or choose an existing one, make sure it has at least the AmazonS3ReadOnlyAccess policy attached, and then retrieve its ACCESS_KEY_ID and SECRET_ACCESS_KEY.
  3. Install s3fs-fuse
    sudo amazon-linux-extras install epel
    sudo yum install s3fs-fuse
  4. Create the mount-point directory
    mkdir /my/mountpoint
  5. Prepare the user-wide credential file (only seems useful if you don't reboot)
    echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ~/.passwd-s3fs
    chmod 600 ~/.passwd-s3fs
  6. Mount my S3 bucket for once (until reboot)
    s3fs my-s3-bucket /my/mountpoint -o passwd_file=./.passwd-s3fs
  7. Prepare to mount S3 bucket on boot
    1. Prepare the system-wide credential file (THIS makes you reboot-proof)
      echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > /etc/passwd-s3fs
      chmod 600 /etc/passwd-s3fs
    2. Add either rule to /etc/fstab
      • To mount at boot as root user:
        sudo echo "my-s3-bucket /my/mountpoint fuse.s3fs _netdev,allow_other 0 0" >> /etc/fstab
      • To mount at boot as current user:
        sudo echo "my-s3-bucket /my/mountpoint fuse.s3fs _netdev,allow_other,default_permissions,user,uid=1000,gid=1000 0 0" >> /etc/fstab
        where uid=$(id -u) and gid=$(id -g)
    3. Install netfs
      cd /usr/local/lib
      sudo wget https://anduin.linuxfromscratch.org/BLFS/blfs-bootscripts/blfs-bootscripts-20220722.tar.xz
      sudo tar -xf blfs-bootscripts-20220722.tar.xz
      cd blfs-bootscripts-20220722/
      sudo make install-netfs
  8. Reboot, and the S3 bucket will always stay mounted. Changes to my-s3-bucket will always be synced to /my/mountpoint on my EC2.

Version of s3fs being used (s3fs --version)

V1.85(commit:unknown)

Version of fuse being used (pkg-config --modversion fuse, rpm -qi fuse or dpkg -s fuse)

2.9.2

Kernel information (uname -r)

8.10.155-138.670.amzn2.aarch64

GNU/Linux Distribution, if applicable (cat /etc/os-release)

NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"

How to run s3fs, if applicable

[s3fs my-s3-bucket /my/mountpoint -o passwd_file=./.passwd-s3fs] command line
[my-s3-bucket /my/mountpoint fuse.s3fs _netdev,allow_other 0 0] /etc/fstab

# install `s3fs-fuse`
sudo amazon-linux-extras install epel
sudo yum install s3fs-fuse
# create mount-point
mkdir /my/mountpoint
# mount for once
echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ~/.passwd-s3fs
chmod 600 ~/.passwd-s3fs
s3fs my-s3-bucket /my/mountpoint -o passwd_file=./.passwd-s3fs
# prepare to mount on boot
echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > /etc/passwd-s3fs
chmod 600 /etc/passwd-s3fs
sudo echo "my-s3-bucket /my/mountpoint fuse.s3fs _netdev,allow_other 0 0" >> /etc/fstab
# install `netfs`
cd /usr/local/lib
sudo wget https://anduin.linuxfromscratch.org/BLFS/blfs-bootscripts/blfs-bootscripts-20220722.tar.xz
sudo tar -xf blfs-bootscripts-20220722.tar.xz
cd blfs-bootscripts-20220722/
sudo make install-netfs
# restart machine
sudo reboot

ps aux | grep netfs
# but showed no running `netfs` process

sudo /etc/init.d/netfs
# but threw this error: "/etc/init.d/netfs: line 28: /lib/lsb/init-functions: No such file or directory"

s3fs syslog messages (grep s3fs /var/log/syslog, journalctl | grep s3fs, or s3fs outputs)

grep s3fs /var/log/syslog

grep: /var/log/syslog: No such file or directory

journalctl | grep s3fs
After reboot, with ~/.passwd-s3fs only

Dec 20 16:39:29 ip-*-*-*-*.****.compute.internal s3fs[1015]: s3fs: could not determine how to establish security credentials.
Dec 20 16:39:29 ip-*-*-*-*.****.compute.internal mount[1005]: s3fs: could not determine how to establish security credentials.

After reboot, with /etc/passwd-s3fs

Dec 20 16:53:50 ip-*-*-*-*.****.compute.internal s3fs[1068]: init v1.85(commit:unknown) with OpenSSL
Dec 20 16:53:50 ip-*-*-*-*.****.compute.internal s3fs[1068]: s3fs.cpp:s3fs_check_service(3828): Failed to connect region 'us-east-1'(default), so retry to connect region '****'.
Dec 20 16:54:21 ip-*-*-*-*.****.compute.internal kernel: [   1068]     0  1068    45935      598   102400        0             0 s3fs

s3fs outputs

s3fs: missing MOUNTPOINT argument.
Usage: s3fs BUCKET:[PATH] MOUNTPOINT [OPTION]...

Details about issue

Originally created by @Qlub53 on GitHub (Dec 21, 2022). Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/2080 <!-- -------------------------------------------------------------------------- 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. Keep in mind that the commands we provide to retrieve information are oriented to GNU/Linux Distributions, so you could need to use others if you use s3fs on macOS or BSD. --------------------------------------------------------------------------- --> This is to share how I managed to mount my S3 bucket to an AWS EC2 instance. Hopefully it'll help people new to `s3fs` as well as those who are still struggling. 1. Create a `my-s3-bucket` on AWS S3. 2. Create a new IAM User, or choose an existing one, make sure it has at least the [AmazonS3ReadOnlyAccess](https://us-east-1.console.aws.amazon.com/iam/home#/policies/arn%3Aaws%3Aiam%3A%3Aaws%3Apolicy%2FAmazonS3ReadOnlyAccess) policy attached, and then retrieve its ACCESS_KEY_ID and SECRET_ACCESS_KEY. 3. Install `s3fs-fuse` `sudo amazon-linux-extras install epel` `sudo yum install s3fs-fuse` 4. Create the mount-point directory `mkdir /my/mountpoint` 5. Prepare the user-wide [credential file](https://github.com/s3fs-fuse/s3fs-fuse#examples) (only seems useful if you don't reboot) `echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ~/.passwd-s3fs` `chmod 600 ~/.passwd-s3fs` 6. ✅ Mount my S3 bucket for once (until reboot) `s3fs my-s3-bucket /my/mountpoint -o passwd_file=./.passwd-s3fs` 7. Prepare to mount S3 bucket on boot 1. Prepare the system-wide [credential file](https://github.com/s3fs-fuse/s3fs-fuse#examples) (THIS makes you reboot-proof) `echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > /etc/passwd-s3fs` `chmod 600 /etc/passwd-s3fs` 2. Add either rule to `/etc/fstab` - To mount at boot as root user: `sudo echo "my-s3-bucket /my/mountpoint fuse.s3fs _netdev,allow_other 0 0" >> /etc/fstab` - To mount at boot as current user: `sudo echo "my-s3-bucket /my/mountpoint fuse.s3fs _netdev,allow_other,default_permissions,user,uid=1000,gid=1000 0 0" >> /etc/fstab` where `uid`=`$(id -u)` and `gid`=`$(id -g)` 3. [Install](https://www.linuxfromscratch.org/blfs/view/svn/basicnet/netfs.html) `netfs` `cd /usr/local/lib` `sudo wget https://anduin.linuxfromscratch.org/BLFS/blfs-bootscripts/blfs-bootscripts-20220722.tar.xz` `sudo tar -xf blfs-bootscripts-20220722.tar.xz` `cd blfs-bootscripts-20220722/` `sudo make install-netfs` 8. Reboot, and the S3 bucket will ✅ always stay mounted. Changes to `my-s3-bucket` will ✅ always be synced to `/my/mountpoint` on my EC2. #### Version of s3fs being used (`s3fs --version`) V1.85(commit:unknown) #### Version of fuse being used (`pkg-config --modversion fuse`, `rpm -qi fuse` or `dpkg -s fuse`) 2.9.2 #### Kernel information (`uname -r`) 8.10.155-138.670.amzn2.aarch64 #### GNU/Linux Distribution, if applicable (`cat /etc/os-release`) NAME="Amazon Linux" VERSION="2" ID="amzn" ID_LIKE="centos rhel fedora" VERSION_ID="2" PRETTY_NAME="Amazon Linux 2" ANSI_COLOR="0;33" CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2" HOME_URL="https://amazonlinux.com/" #### How to run s3fs, if applicable <!-- Describe the s3fs "command line" or "/etc/fstab" entry used. --> [`s3fs my-s3-bucket /my/mountpoint -o passwd_file=./.passwd-s3fs`] command line [`my-s3-bucket /my/mountpoint fuse.s3fs _netdev,allow_other 0 0`] /etc/fstab <!-- Executed command line or /etc/fastab entry --> ```sh # install `s3fs-fuse` sudo amazon-linux-extras install epel sudo yum install s3fs-fuse # create mount-point mkdir /my/mountpoint # mount for once echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > ~/.passwd-s3fs chmod 600 ~/.passwd-s3fs s3fs my-s3-bucket /my/mountpoint -o passwd_file=./.passwd-s3fs # prepare to mount on boot echo ACCESS_KEY_ID:SECRET_ACCESS_KEY > /etc/passwd-s3fs chmod 600 /etc/passwd-s3fs sudo echo "my-s3-bucket /my/mountpoint fuse.s3fs _netdev,allow_other 0 0" >> /etc/fstab # install `netfs` cd /usr/local/lib sudo wget https://anduin.linuxfromscratch.org/BLFS/blfs-bootscripts/blfs-bootscripts-20220722.tar.xz sudo tar -xf blfs-bootscripts-20220722.tar.xz cd blfs-bootscripts-20220722/ sudo make install-netfs # restart machine sudo reboot ps aux | grep netfs # but showed no running `netfs` process sudo /etc/init.d/netfs # but threw this error: "/etc/init.d/netfs: line 28: /lib/lsb/init-functions: No such file or directory" ``` #### s3fs syslog messages (`grep s3fs /var/log/syslog`, `journalctl | grep s3fs`, or `s3fs outputs`) <!-- if you execute s3fs with dbglevel, curldbg option, you can get detail debug messages. --> `grep s3fs /var/log/syslog` ``` grep: /var/log/syslog: No such file or directory ``` `journalctl | grep s3fs` After reboot, with ~/.passwd-s3fs only ``` Dec 20 16:39:29 ip-*-*-*-*.****.compute.internal s3fs[1015]: s3fs: could not determine how to establish security credentials. Dec 20 16:39:29 ip-*-*-*-*.****.compute.internal mount[1005]: s3fs: could not determine how to establish security credentials. ``` After reboot, with /etc/passwd-s3fs ``` Dec 20 16:53:50 ip-*-*-*-*.****.compute.internal s3fs[1068]: init v1.85(commit:unknown) with OpenSSL Dec 20 16:53:50 ip-*-*-*-*.****.compute.internal s3fs[1068]: s3fs.cpp:s3fs_check_service(3828): Failed to connect region 'us-east-1'(default), so retry to connect region '****'. Dec 20 16:54:21 ip-*-*-*-*.****.compute.internal kernel: [ 1068] 0 1068 45935 598 102400 0 0 s3fs ``` `s3fs outputs` ``` s3fs: missing MOUNTPOINT argument. Usage: s3fs BUCKET:[PATH] MOUNTPOINT [OPTION]... ``` ### Details about issue <!-- Please describe the content of the issue in detail. -->
kerem closed this issue 2026-03-04 01:50:58 +03:00
Author
Owner

@Qlub53 commented on GitHub (Dec 21, 2022):

Pro tip1️⃣ of the day 🚀 - credential file: system-wide 🆚 user-wide?

Use system-wide /etc/passwd-s3fs once and for all.
Because user-wide ~/.passwd-s3fs only works when you manually run s3fs -o and only stays in effect until reboot, while system-wide /etc/passwd-s3fs additionally allows mounting on boot.

When using user-wide ~/.passwd-s3fs and after reboot, journalctl | grep s3fs logs failure:

Dec 20 16:39:29 ip-*-*-*-*.****.compute.internal s3fs[1015]: s3fs: could not determine how to establish security credentials.
Dec 20 16:39:29 ip-*-*-*-*.****.compute.internal mount[1005]: s3fs: could not determine how to establish security credentials.

When using system-wide /etc/passwd-s3fs and after reboot, journalctl | grep s3fs logs success:

Dec 20 16:53:50 ip-*-*-*-*.****.compute.internal s3fs[1068]: init v1.85(commit:unknown) with OpenSSL
Dec 20 16:53:50 ip-*-*-*-*.****.compute.internal s3fs[1068]: s3fs.cpp:s3fs_check_service(3828): Failed to connect region 'us-east-1'(default), so retry to connect region '****'.
Dec 20 16:54:21 ip-*-*-*-*.****.compute.internal kernel: [   1068]     0  1068    45935      598   102400        0             0 s3fs
<!-- gh-comment-id:1360821318 --> @Qlub53 commented on GitHub (Dec 21, 2022): ### Pro tip1️⃣ of the day 🚀 - credential file: system-wide 🆚 user-wide? Use **system-wide** `/etc/passwd-s3fs` once and for all. Because user-wide `~/.passwd-s3fs` only works when you manually run `s3fs -o` and only stays in effect until reboot, while **system-wide** `/etc/passwd-s3fs` additionally allows mounting on boot. When using user-wide `~/.passwd-s3fs` and after reboot, `journalctl | grep s3fs` logs failure: ``` Dec 20 16:39:29 ip-*-*-*-*.****.compute.internal s3fs[1015]: s3fs: could not determine how to establish security credentials. Dec 20 16:39:29 ip-*-*-*-*.****.compute.internal mount[1005]: s3fs: could not determine how to establish security credentials. ``` When using **system-wide** `/etc/passwd-s3fs` and after reboot, `journalctl | grep s3fs` logs success: ``` Dec 20 16:53:50 ip-*-*-*-*.****.compute.internal s3fs[1068]: init v1.85(commit:unknown) with OpenSSL Dec 20 16:53:50 ip-*-*-*-*.****.compute.internal s3fs[1068]: s3fs.cpp:s3fs_check_service(3828): Failed to connect region 'us-east-1'(default), so retry to connect region '****'. Dec 20 16:54:21 ip-*-*-*-*.****.compute.internal kernel: [ 1068] 0 1068 45935 598 102400 0 0 s3fs ```
Author
Owner

@Qlub53 commented on GitHub (Dec 21, 2022):

Pro tip2️⃣ of the day 🚀 - NetFS

README.md says:

Note2: You may also need to make sure netfs service is start on boot

There aren't much information about netfs online, as far as I have explored.

I followed this link https://www.linuxfromscratch.org/blfs/view/svn/basicnet/netfs.html to install netfs.
Refer to "Install netfs" from above for more. ls -l /etc/init.d/ | grep netfs to check if installed.

<!-- gh-comment-id:1360823018 --> @Qlub53 commented on GitHub (Dec 21, 2022): ### Pro tip2️⃣ of the day 🚀 - NetFS [README.md](https://github.com/s3fs-fuse/s3fs-fuse/blame/master/README.md#L143) says: > Note2: You may also need to make sure `netfs` service is start on boot There aren't much information about `netfs` online, as far as I have explored. I followed this link https://www.linuxfromscratch.org/blfs/view/svn/basicnet/netfs.html to install `netfs`. Refer to "Install `netfs`" from [above](https://github.com/s3fs-fuse/s3fs-fuse/issues/2080#issue-1505667893) for more. `ls -l /etc/init.d/ | grep netfs` to check if installed.
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#1053
No description provided.