Here’s how to mount Linode S3-compatible Object Storage on Debian 12 (Bookworm), put the access key and secret on /var/app/secret/ and assign it to the user exampleuser.

Here’s how to mount Linode S3-compatible Object Storage on Debian 12 (Bookworm) and assign it to the user exampleuser:

1. Install Prerequisites

Update your system and install s3fs:

sudo apt update
sudo apt install -y s3fs

2. Set Up Credentials

Create a file to store the Linode S3 access keys securely. Use the /var/app/secret/credentials file as specified:

echo "LINODE_ACCESS_KEY:LINODE_SECRET_KEY" > /var/app/secret/credentials
sudo chmod 600 /var/app/secret/credentials

Replace:

  • LINODE_ACCESS_KEY with your Linode Access Key.
  • LINODE_SECRET_KEY with your Linode Secret Key.

3. Create a Mount Point

Create the directory where the object storage will be mounted:

sudo mkdir -p /mnt/linode-s3

4. Determine User and Group IDs

Find the UID and GID of the user exampleuser:

id exampleuser

Example output:

uid=1001(exampleuser) gid=1001(exampleuser) groups=1001(exampleuser)

Take note of the uid and gid (in this case, 1001).

5. Mount the Object Storage

Mount the S3 bucket and assign ownership to exampleuser. Replace BUCKET_NAME with your bucket’s name and <ENDPOINT> with your Linode Object Storage endpoint:

s3fs BUCKET_NAME /mnt/linode-s3 -o url=https://<ENDPOINT> -o use_path_request_style -o passwd_file=/var/app/secret/credentials -o uid=1001 -o gid=1001

Example for a bucket named my-bucket:

s3fs my-bucket /mnt/linode-s3 -o url=https://us-east-1.linodeobjects.com -o use_path_request_style -o passwd_file=/var/app/secret/credentials -o uid=1001 -o gid=1001

6. Verify the Mount

Check the ownership and permissions of the mounted directory:

ls -ld /mnt/linode-s3

Expected output:

drwxr-xr-x 1 exampleuser exampleuser 4096 Dec  2 12:00 /mnt/linode-s3

List the contents of the bucket:

ls /mnt/linode-s3

7. Configure Auto-Mount on Boot

To automatically mount the S3 bucket on system reboot, add an entry to /etc/fstab:

sudo nano /etc/fstab

Add the following line, replacing placeholders with your bucket and credentials:

s3fs#my-bucket /mnt/linode-s3 fuse _netdev,url=https://us-east-1.linodeobjects.com,use_path_request_style,passwd_file=/var/app/secret/credentials,uid=1001,gid=1001 0 0

Save and exit the file (Ctrl+O, Enter, Ctrl+X).

8. Test the Configuration

Reboot the system to ensure the auto-mount works:

sudo reboot

After reboot, check the mount point:

ls /mnt/linode-s3

Optional: Adjust Permissions

If you need specific file and directory permissions, you can add umask to the mount options. For example, to set 755 permissions for directories and files:

-o umask=0022

Your Linode S3-compatible Object Storage is now mounted and assigned to the user exampleuser.

Leave A Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.