How to automatically mount S3 bucket right after connecting to EC2 instances

2.9k views Asked by At

Usually everytime I connected(start or restart) my instances I have to manually mount the S3 bucket to it. I do it with the following command using Goofys (or alternatively s3fs)

ubuntu@ip-172-00-23-230:~$ ./go/bin/goofys mybucket my_mountdir

Is there away I can automatically mount it everytime I login to my instances

3

There are 3 answers

2
Sarvex On

With Linux you automatically mount the drives using fstab; which requires special drivers for different filesystems.

You should install the fuse drivers and add entry for s3 bucket in /etc/fstab

Update

There is a new open source project simplifying the things https://github.com/s3fs-fuse/s3fs-fuse

0
khc On

goofys' README addressed this use case: https://github.com/kahing/goofys/

In short:

To mount an S3 bucket on startup, make sure the credential is configured for root, and can add this to /etc/fstab:

goofys#bucket /mnt/mountpoint fuse _netdev,allow_other,--file-mode=0666 0 0

0
Biswajit Mohanty On

Create a new script in /etc/init.d/mountbucket

sudo vi /etc/init.d/mountbucket

write the line you want to execute :-

#!/bin/sh
/home/ubuntu/go/bin/goofys mybucket my_mountdir

make it excutable

sudo chmod ugo+x /etc/init.d/mountbucket

update to start in each system restart

sudo update-rc.d mountbucket defaults