Skip to content

trouble writing to s3 bucket using mount-s3 on Linux as mount (non-root) user

0

Hello - I have a basic EC2 (AML2023) that mounts an s3 bucket (ex: my-foo-bucket) to a directory /mnt/data-vol/my-foo-bucket. It's mounted successfully through /etc/fstab. My problem is that I can read from the bucket via a filesystem command, but can not write to the bucket. Under normal circumstances, the user would not have an interactive shell, but for troubleshooting, I have provided it temporarily.

from: /etc/fstab s3://my-foo-bucket/ /mnt/data-vol/my-foo-bucket mount-s3 _netdev,nosuid,nodev,nofail,rw,allow-other,uid=992,gid=1002,cache=/mnt/data-vol/cache 0 0

UID and GID are accurate.

If I login (su to user) as the user, cd to the s3 bucket mount point and copy a file from /tmp to "./", I get an error bash-5.2$ cp /tmp/test.txt . cp: error writing './test.txt': Input/output error cp: failed to close './test.txt': Input/output error

I'm new to /etc/fstab and mount-s3, so I'm hoping I have an obvious mistake. I used examples from the AWS docs for the _netdev, nosuid and nodev, and am wondering if "nodev" might have something to do with it. Any recommendations would be much appreciated.

asked 6 months ago585 views
2 Answers
0
Accepted Answer

The issue you're experiencing with writing to your mounted S3 bucket is likely due to the read-only nature of Mountpoint for Amazon S3. By default, Mountpoint for Amazon S3 mounts buckets in read-only mode.

Looking at your error message "Input/output error" when trying to write a file, this is consistent with attempting to write to a read-only mount. Even though you've specified the "rw" option in your fstab configuration, Mountpoint for S3 doesn't support write operations in the same way traditional filesystems do.

When applications try to overwrite existing files on a Mountpoint for S3 mount, the operation fails with errors similar to what you're seeing. The logs would typically show a warning message indicating that the inode is not writable.

To resolve this issue:

  1. Check your IAM permissions - ensure the EC2 instance role has proper S3 permissions (s3:PutObject) for the bucket
  2. If you need write capabilities to S3, consider using AWS CLI commands (aws s3 cp) or SDK operations instead of filesystem operations through the mount
  3. Alternatively, you could use a different S3 mounting solution that supports write operations

The "nodev" option in your fstab configuration is not causing this issue - it's related to preventing device file interpretation on the mounted filesystem.
Sources
Troubleshooting Mountpoint - Amazon Simple Storage Service
Lamba write to s3 not working unless with FullAccess iam role | AWS re:Post

answered 6 months ago
EXPERT
reviewed 6 months ago
0

The answer was the EC2 Instance Profile only had read from the s3 bucket in question. I was so focused on the "newness" of mount-s3 and /etc/fstab that I missed the underlying instance profile. Problem resolved.

answered 6 months ago
AWS
EXPERT
reviewed 6 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.