Skip to content

Expand storage to AWS S3

Thomas T. Jarløv edited this page Oct 7, 2018 · 5 revisions

If you are using a Raspberry Pi camera (onboard/USB/etc.) to monitor when the alarm is triggered, it is a good idea to backup the photos and videos in cloud - in the case the thief steals you RPi.

The following guide shows how to mount a AWS S3 to the Raspberry Pi.

Requirements

  • AWS account
  • AWS key and secret

Create AWS bucket

Create bucket: nimha

Create folder: pictures (this will be nimha/pictures)

Download packages

sudo apt install s3fs

Add key and secret

nano /home/pi/nimha/.passwd-s3fs

Insert:

key:secret

Set permission:

chmod 600 /home/pi/nimha/.passwd-s3fs

Create mount point

sudo mkdir /mnt/nimha
chown pi:pi /mnt/nimha

Allow other than root user to access

nano /etc/fuse.conf
  • uncomment: user_allow_other

Get user and group id

id

Find your user and group id - could be 1000 for both. They are needed in the umask detail.

Mount

s3fs nimha /mnt/nimha -o umask=1000 -o passwd_file=/home/pi/nimha/.passwd-s3fs -o endpoint=eu-west-1 -o allow_other

Umount (not needed)

fusermount /mnt/nimha

Create system service for auto mount

mkdir ~/.config/systemd/user
nano ~/.config/systemd/user/s3fs.service

Adjust to your details and insert

[Unit]
Description=S3FS mounts
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/s3fs nimha /mnt/nimha -o umask=1000 -o passwd_file=/home/pi/nimha/.passwd-s3fs -o endpoint=eu-west-1 -o allow_other
ExecStop=/bin/fusermount -u /mnt/nimha

[Install]
WantedBy=default.target

Start on boot and start

systemctl --user enable s3fs
systemctl --user start s3fs