Search

Search IconIcon to open search

s3fs-fuse

Last updatedUpdated: by Simon Späti · CreatedCreated:

  • s3fs allows Linux, macOS, and FreeBSD to mount an S3 bucket via  FUSE(Filesystem in Userspace).
  • s3fs makes you operate files and directories in S3 bucket like a local file system.
  • s3fs preserves the native object format for files, allowing use of other tools like  AWS CLI.

GitHub

# Setup with S3

Or check YouTube:

Install s3fs-fuse:

1
sudo pacman -S s3fs-fuse

Create credentials file (optional if using environment variables):

1
2
echo "$AWS_ACCESS_KEY_ID:$AWS_SECRET_ACCESS_KEY" > ~/.passwd-s3fs
chmod 600 ~/.passwd-s3fs

Mount the sspaeti bucket:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
# Create mount point in home directory (no sudo needed)
mkdir -p ~/mnt/s3/sspaeti

# Mount the bucket - specify correct endpoint for your region
s3fs sspaeti ~/mnt/s3/sspaeti -o endpoint=eu-central-1

# Alternative: using credentials file explicitly
s3fs sspaeti ~/mnt/s3/sspaeti -o passwd_file=~/.passwd-s3fs,endpoint=eu-central-1

# For system-wide mount (requires sudo):
sudo mkdir -p /mnt/s3/sspaeti
sudo s3fs sspaeti /mnt/s3/sspaeti -o passwd_file=/home/$(whoami)/.passwd-s3fs,endpoint=eu-central-1,allow_other,uid=$(id -u),gid=$(id -g)

Unmount when done:

1
2
3
4
5
# For home directory mount
fusermount -u ~/mnt/s3/sspaeti

# For system mount
sudo umount /mnt/s3/sspaeti

Important Notes:

  • Use home directory (~/) to avoid needing sudo - mounting to /mnt/ or other system directories requires root permissions
  • Specify the correct endpoint - use endpoint=eu-central-1 for EU buckets, endpoint=us-west-2 for US West, etc.
  • If your AWS credentials are already in environment variables, s3fs-fuse will pick them up automatically without needing the .passwd-s3fs file
  • When using sudo, the ~ path doesn’t expand correctly - use full paths like /home/$(whoami)/

AWS S3 setup see AWS S3.

# Create persistent Mounts

Above solution is gone after reboot, if you want persistence, we need to use fstab.

1
2
3
4
# Create mount points if they don't exist
sudo mkdir -p /mnt/s3/sspaeti
sudo mkdir -p /mnt/synology/backup
sudo mkdir -p /mnt/synology/photo

Above credentials still need to be created or are been used here - check if they exist:

1
2
ls ~/.passwd-s3fs
sudo cat /etc/cifs-credentials

Edit fstab config with sudo nvim /etc/fstab and add e.g. for my synology (Adding Network Drive - NAS Synology) and S3 drive the following configs:

1
2
3
4
5
6
# S3 mount via s3fs
sspaeti /mnt/s3/sspaeti fuse.s3fs _netdev,allow_other,use_path_request_style,url=https://s3.eu-central-1.amazonaws.com,endpoint=eu-central-1,uid=1000,gid=1000,passwd_file=/home/sspaeti/.passwd-s3fs 0 0

# Synology CIFS mounts
//192.168.1.111/backup /mnt/synology/backup cifs _netdev,credentials=/etc/cifs-credentials,uid=1000,gid=1000,iocharset=utf8 0 0
//192.168.1.111/photo /mnt/synology/photo cifs _netdev,credentials=/etc/cifs-credentials,uid=1000,gid=1000,iocharset=utf8 0 0

# mount defined fstab configs

just run:

1
sudo mount -a   

# Others

Enable allow_other for s3fs with:

Edit fuse config sudo nvim /etc/fuse.conf

1
2
# Uncomment this line (remove the # if present):
user_allow_other

unmount with:

1
2
3
4
5
Unmount all fuse.s3fs filesystems:
sudo umount -a -t fuse.s3fs

Or unmount all mounts under /mnt/s3:
Osudo umount /mnt/s3/*

What does user_allow_other do?

The user_allow_other setting in /etc/fuse.conf allows non-root users to use the allow_other mount option with FUSE filesystems. By default, FUSE mounts are only accessible by the user who mounted them. allow_other makes the mount accessible to all users on the system

Single user system? You don’t need allow_other

If you’re the only user on your system, you can skip the allow_other option and the fuse.conf change for better security.

Check your user ID with:

1
2
id -u  # Should return 1000
id -g  # Should return 1000

If your uid/gid match what’s in the fstab entry (1000), simply remove allow_other from the s3fs line:

1
sspaeti /mnt/s3/sspaeti fuse.s3fs _netdev,use_path_request_style,url=https://s3.eu-central-1.amazonaws.com,endpoint=eu-central-1,uid=1000,gid=1000,passwd_file=/home/sspaeti/.passwd-s3fs 0 0

And keep user_allow_other commented in /etc/fuse.conf. The mount will still work perfectly and be more secure.

# Test the mounts without rebooting

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# Test mounting all entries in fstab
sudo mount -a

# Verify they're mounted
mount | grep s3fs
mount | grep cifs

# Check if you can see files
ls /mnt/s3/sspaeti
ls /mnt/synology/backup
ls /mnt/synology/photo

# Setup Yazi with DuckDB

Using the DuckDB plugin on yazi to preview data files, which works for all local files, but also with S3 if you have set it up as above.

See more at yazi or directly on GitHub


Origin: stu
References: On MacOS see Mounting Amazon S3 as a File System, Adding Network Drive - NAS Synology