In today’s post, we’ll learn how to mount an AWS S3 bucket as a local directory on a Linux system. While this approach should work across most Linux distributions, I’ve tested it specifically on my home lab setup using a Raspberry Pi as the host.
This method allows seamless interaction with your S3 storage as if it were part of your local filesystem — ideal for backups, file syncing, or lightweight storage needs.
Package installation
You can install Mountpoint for Amazon S3 using prebuilt packages directly from the command line. Installation steps may vary slightly depending on your Linux distribution, so ensure you follow the instructions specific to your OS version.
Mountpoint enables you to interact with your S3 bucket as a native file system, making cloud storage integration simple and efficient.
Before proceeding, we need to configure the AWS CLI with your credentials. If you haven’t set it up yet, follow the steps in the following blog:
To use Mountpoint for Amazon S3, your host needs valid AWS credentials with access to the Amazon S3 bucket or buckets that you would like to mount. For different ways to authenticate, see Mountpoint AWS Credentials on GitHub.
For example, you can create a new AWS Identity and Access Management (IAM) user and role for this purpose. Make sure that this role has access to the bucket or buckets that you would like to mount. You can pass the IAM role to your Amazon EC2 instance with an instance profile.
You can download and install prebuilt packages of Mountpoint for Amazon S3 by using the command line. The instructions for downloading and installing Mountpoint vary, depending on which Linux operating system you’re using. Hence, I am using Raspberry Pi, and I will be proceeding with an arm64-based package:
wget https://s3.amazonaws.com/mountpoint-s3-release/latest/arm64/mount-s3.deb
dpkg -i mount-s3.deb
Refer to the following URL for more details:
https://docs.aws.amazon.com/AmazonS3/latest/userguide/mountpoint-installation.html
With AWS CLI configured, the next step is to create a local mount point where the S3 bucket will be attached. You can do this with a simple command:
mkdir ~/mnt
mount-s3 amzn-s3-demo-bucket ~/mnt_s3
Replace /mnt With your preferred directory path and amzn-s3-demo-bucket your bucket name. This directory will serve as the local access point to your S3 bucket.
Once the S3 bucket is successfully mounted, you can verify it using the following command. This will list all mounted file systems, and you should see your S3 bucket listed along with its mount point and usage details.
How to make the mounting persistent?
To mount the S3 bucket permanently, you can use a systemd service or a startup script. Here’s how to do it using a systemd unit file:
sudo vi /etc/systemd/system/s3bucketmount.service
Add the following contents to the file:
[Unit]
Description=S3 Filesystem Mount
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/usr/bin/mount-s3 amzn-s3-demo-bucket ~/mnt_s3 --allow-delete --allow-other
ExecStop=/bin/fusermount -u ~/mnt_s3
Restart=always
User=root
[Install]
WantedBy=multi-user.target
Now reload the system daemon and enable the service:
sudo systemctl daemon-reexec
sudo systemctl daemon-reload
sudo systemctl enable --now s3bucketmount.service
sudo systemctl status s3bucketmount
Mounting an Amazon S3 bucket as a local filesystem on a Linux machine offers a flexible and efficient way to interact with cloud storage. Whether you’re managing backups, automating workflows, or building a home lab setup, this method ensures seamless integration between your local environment and AWS.
With mount-s3, AWS CLI, and systemd, you can achieve a reliable, persistent mount that simplifies data access and improves productivity.
Top comments (0)