Ubuntu – How to force s3fs mount on boot

amazon s3fuses3fsUbuntu

I'm using s3fs 1.33 on Ubuntu 9.10 x86.

I mount it manually with this command:

sudo /usr/bin/s3fs mybucket /mnt/s3/mybucket -ouse_cache=/tmp

How can I force the mount on boot?

I guess that I have to write something to /etc/fstab. But what? And how do I test it without rebooting the server?

Best Answer

Follow the Ubuntu RcLocalHowto to create /etc/init.d/local, and then put your command in that file. The mount will then happen automatically on boot.

To test, invoke /etc/init.d/local manually on the command line (as root). You should see that causes the mount to occur.

EDIT: doing the mount from /etc/fstab should work fine too, according to the s3fs faq:

s3fs#example.com /mnt/s3/blah fuse _netdev,use_cache=/tmp,use_rrs=1,allow_other 0 0

Reason to prefer the /etc/init.d/local approach: it's simpler to set up, just put your existing mount script in that file.

Reason to prefer the fstab approach: it's a more standard way to do mounts, and someone who doesn't know about your setup can just look in /etc/fstab to determine what mounts your machine is making.