[GH-ISSUE #111] Service file to run as service and automatically mount on boot (start, stop, restart, status ) #67

Closed
opened 2026-03-04 01:41:44 +03:00 by kerem · 6 comments
Owner

Originally created by @shivanandsharma on GitHub (Jan 22, 2015).
Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/111

#!/bin/sh

# chkconfig: 2345 20 80
# description: Mounts the S3 bucket varun21-backups to /mys3bucket
# Created by Shivanand Sharma BinaryTurf.Com
# License: GPL 3 and "don't blame me".
# Usage:
#   Edit the relevant sections of this file like your bucket name and mount point
#   copy this file into /etc/init.d/
#   sudo chkconfig --add mounts3
#   sudo service mounts3 start
#   Optional: Configure required runlevels for the service

start() {
echo -n $"Starting..."
sudo s3fs varun21-backups /mys3bucket
sudo ls -al /mys3bucket
}

stop() {
echo -n $"Stopping..."
sudo umount /mys3bucket
}

reload(){
sudo umount /mys3bucket
sudo s3fs varun21-backups /mys3bucket
sudo ls -al /mys3bucket
}

status(){
sudo ls -al /mys3bucket
}

# See how we were called.
case "$1" in
start)
     start
     ;;
stop)
     stop
     ;;
status)
     status
     ;;
restart)
     stop
     start
     ;;
reload)
     reload
     ;;
*)
     echo $"Usage: $prog {start|stop|restart|status}"
     RETVAL=2
esac

exit $RETVAL
Originally created by @shivanandsharma on GitHub (Jan 22, 2015). Original GitHub issue: https://github.com/s3fs-fuse/s3fs-fuse/issues/111 ``` #!/bin/sh # chkconfig: 2345 20 80 # description: Mounts the S3 bucket varun21-backups to /mys3bucket # Created by Shivanand Sharma BinaryTurf.Com # License: GPL 3 and "don't blame me". # Usage: # Edit the relevant sections of this file like your bucket name and mount point # copy this file into /etc/init.d/ # sudo chkconfig --add mounts3 # sudo service mounts3 start # Optional: Configure required runlevels for the service start() { echo -n $"Starting..." sudo s3fs varun21-backups /mys3bucket sudo ls -al /mys3bucket } stop() { echo -n $"Stopping..." sudo umount /mys3bucket } reload(){ sudo umount /mys3bucket sudo s3fs varun21-backups /mys3bucket sudo ls -al /mys3bucket } status(){ sudo ls -al /mys3bucket } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status ;; restart) stop start ;; reload) reload ;; *) echo $"Usage: $prog {start|stop|restart|status}" RETVAL=2 esac exit $RETVAL ```
kerem closed this issue 2026-03-04 01:41:44 +03:00
Author
Owner

@ggtakec commented on GitHub (Mar 8, 2015):

Thanks a codes for service.

I'm wander about that normally s3fs should start to run with fstab on boot, do you think about it?
I think that this script is good for not root user, not service.
(for service, I think it is needed to change some(ex, using configuration file instead of bucket name and mount point hard coding))

Regards,

<!-- gh-comment-id:77745820 --> @ggtakec commented on GitHub (Mar 8, 2015): Thanks a codes for service. I'm wander about that normally s3fs should start to run with fstab on boot, do you think about it? I think that this script is good for not root user, not service. (for service, I think it is needed to change some(ex, using configuration file instead of bucket name and mount point hard coding)) Regards,
Author
Owner

@ggtakec commented on GitHub (Mar 30, 2019):

We kept this issue open for a long time.
I will close this, but if the problem persists, please reopen or post a new issue.

<!-- gh-comment-id:478212949 --> @ggtakec commented on GitHub (Mar 30, 2019): We kept this issue open for a long time. I will close this, but if the problem persists, please reopen or post a new issue.
Author
Owner

@abhishekk27 commented on GitHub (May 11, 2020):

I'm still facing the issue,
s3fs#<bucket-name> <host-folder> fuse retries=5,allow_other,url=https://s3-us-east-2.amazonaws.com 0 0
the mount is unmounting after I boot my server

<!-- gh-comment-id:626702689 --> @abhishekk27 commented on GitHub (May 11, 2020): I'm still facing the issue, `s3fs#<bucket-name> <host-folder> fuse retries=5,allow_other,url=https://s3-us-east-2.amazonaws.com 0 0` the mount is unmounting after I boot my server
Author
Owner

@sharmashivanand commented on GitHub (May 11, 2020):

Have you enabled the service?
Have you updated the bubcket name accordingly?
What is the output of journalctl?

<!-- gh-comment-id:626711017 --> @sharmashivanand commented on GitHub (May 11, 2020): Have you enabled the service? Have you updated the bubcket name accordingly? What is the output of journalctl?
Author
Owner

@abhishekk27 commented on GitHub (May 11, 2020):

yeah, it is working when I'm running
sudo mount <folder-name>
but after the restart, the mount is not present

<!-- gh-comment-id:626853792 --> @abhishekk27 commented on GitHub (May 11, 2020): yeah, it is working when I'm running `sudo mount <folder-name>` but after the restart, the mount is not present
Author
Owner

@juliogonzalez commented on GitHub (May 11, 2020):

While the service on the description is nice, it would be way better if it could do some things:

  1. Have a variable for the bucketname, and the mount point.
  2. Refuse to start if the mount point does not exist, or if can be used for mounting.
  3. Support for options.

In fact it should most probably ship an /etc/default/s3fs-fuse file as well.

But all of that should be part of a system package.

Besides of what @ggtakec said, now that a lot of distributions are shipping systemd all problems you are having could be because of the way systemd is using this sysvinit script.

And in the end I am wondering: you have /etc/fstab. What's the exactly the use case? Why do you need to use a service instead of fstab? I am sure there's a use case, but can you explain?

<!-- gh-comment-id:626862028 --> @juliogonzalez commented on GitHub (May 11, 2020): While the service on the description is nice, it would be way better if it could do some things: 1. Have a variable for the bucketname, and the mount point. 2. Refuse to start if the mount point does not exist, or if can be used for mounting. 3. Support for options. In fact it should most probably ship an /etc/default/s3fs-fuse file as well. But all of that should be part of a system package. Besides of what @ggtakec said, now that a lot of distributions are shipping `systemd` all problems you are having could be because of the way `systemd` is using this `sysvinit` script. And in the end I am wondering: you have `/etc/fstab`. What's the exactly the use case? Why do you need to use a service instead of `fstab`? I am sure there's a use case, but can you explain?
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/s3fs-fuse#67
No description provided.