Search code examples
amazon-ec2amazon-web-servicess3fs

S3 buckets randomly unmount on EC2 instance


My company currently is using S3fs and Ec2 from AWS. We have been mounted our s3 buckets on our Ec2 instances, but after some time (a week, for example) some of the buckets unmount by themselves and our server instances become nearly useless. The error is "Transport endpoint not connected."

S3fs version: 1.61 build from source

FUSE version: 2.84.1 build from source

OS: Linux, Ubuntu 11.04

Is there some kind of safe mechanism for preventing (or at least detecting) these problems?


Solution

  • Great insight. Hadn't thought about this. But here are 3 precautionary steps we can take:

    1) Create an auto-mount so that in the very unlikely event that EC2 is down, S3 gets mounted back on once EC2 comes back via /etc/fstab

    2) or/and if you prefer, create a secondary auto-mount using cron:

    echo "/usr/bin/s3fs [s3 bucket name] [mountpoint path] -o allow_other" >> automount-s3
    sudo mv automount-s3 /usr/sbin
    sudo chown root:ubuntu /usr/sbin/automount-s3
    sudo chmod +x /usr/sbin/automount-s3
    
    crontab -e
    

    add this line

    @reboot /usr/sbin/automount-s3
    

    3) I would also create another hourly cron to check whether S3 is still mounted - this can be done by checking if a dummy file exists in your EC2 path. If the file doesn't exist, cron will do a manual mount by calling "/usr/bin/s3fs -o allow_other [s3 bucket name] [mountpoint path]". It would be good to trigger an email to the admin and log it in the system as well.