How to unmount sshfs share when stopping/shutting down array


Recommended Posts

I have two remote file systems mounted on my unraid machine under the /mnt/cache/.watch/ directory. When I stop the array it hangs on unmounting disks until I manually go in and unmount the the two sshfs mounts.

 

I have a couple questions about how to get these shares to automatically mount or unmount whenever I: start, stop, power on, or power off the array.

 

Power on

So for having them mount when I first power up the machine I simply placed these two lines in my go file:

#!/bin/bash
# Start the Management Utility
/usr/local/sbin/emhttp &
sshfs [email protected]:private/deluge/data/couchpotato/ /mnt/cache/.watch/movies/ -o allow_other -o Ciphers=arcfour -o Compression=no -o IdentityFile=/mnt/cache/.watch/AutomationSetup
sshfs [email protected]:private/deluge/data/sonarr/ /mnt/cache/.watch/tv-remote/ -o allow_other -o Ciphers=arcfour -o Compression=no -o IdentityFile=/mnt/cache/.watch/AutomationSetup

I haven't tested that these lines work yet (haven't restarted the server lately) but they should work unless I am completely missing something. See my post over in this thread if you are intested in setting up something similar to what I have: https://lime-technology.com/forum/index.php?topic=49884.msg488512#msg488512

 

Power off

I assume for this I just need to edit the clean powerdown plugin to add the relevant umount lines? Or will it handle removing any and all mounts upon executing a power down?

 

Start/Stop Array

I was looking around the forums and found this old thread: http://lime-technology.com/forum/index.php?topic=26201.0

Is this still the best/recommended way to deal with having commands run when the array is started or stopped? If not what is the best way to go about having this setup?

Link to comment
  • 2 weeks later...

Start/Stop Array

I was looking around the forums and found this old thread: http://lime-technology.com/forum/index.php?topic=26201.0

Is this still the best/recommended way to deal with having commands run when the array is started or stopped? If not what is the best way to go about having this setup?

Yup, that still works, and is how plugins handle it.

Awesome thanks for the info. Can anyone clarify if the clean powerdown plugin is capable of unmounting SSHFS shares or will I need to figure out a way to modify it and add support for it?

Link to comment

So looking through that thread again I found dlandon's post that references some added and very useful plugin developer features: http://lime-technology.com/forum/index.php?topic=31735.msg288775#msg288775.

 

Just to make sure I understand what he is saying correctly (dlandon if you find this feel free to chime in):

By using the KXX.sh and SXX.sh files he is talking about I can mount and unmount my sshfs mounts when the array is being stopped (but only when powerdown is the process initiating the shutdown) and mount them when unRAID starts up, correct? So I would no longer need those lines in my go file as long as I keep the powerdown plugin installed?

 

I would still then need a way to mount and unmount the shares when I am starting/stopping the array from the webUI without the powerdown script being involved correct?

 

 

Edit:

 

Ok so I created the K00.sh and S00.sh files and they seem to be working fine:

-When I start the array (after having previously stopped the array) my remote mounts are created just fine.

-When I stop the array they are removed fine.

-When I power off the machine they are removed just fine.

 

The one thing I am still having issues with is getting them to mount when I first start the server. I first tried to follow what Dreded talked about in his post here: http://lime-technology.com/forum/index.php?topic=26201.msg272564#msg272564

 

I created a script and stored it in /boot/config/plugins/sshfs/mounting and added my relevant sshfs mount commands to the file. I then created go file entries to copy the file into the appropriate directories like he did:

mkdir -p /usr/local/emhttp/plugins/sshfs/event/mount

cp /boot/config/plugins/sshfs/mounting /usr/local/emhttp/plugins/sshfs/event/mount/

chmod +x  /usr/local/emhttp/plugins/sshfs/event/mount/mounting

 

I rebooted the server and the sshfs mounts were never created. I checked the syslog and didn't see any errors mentioned regarding sshfs or the local directory I was mounting to.

 

I next tried to just put the mount commands directly into the go file which fuse didn't like. During boot I got three errors on the screen all referencing the local mount point saying:

/mnt/cache/.watch/tv-remote: no such file or directory

/mnt/cache/.watch/movies: no such file or directory

/mnt/cache/.watch/music-remote: no such file or directory

 

I guess this must be because the go file is ran before the cache disks are mounted?

 

EDIT2: Also It appears as though docker is starting before my shares are being mounted so the remote file systems aren't accessible to my docker container until I manually restart the docker service. Is there a way to make sure docker starts AFTER my sshfs shares have been mounted so I don't need to restart the service?

 

Link to comment
  • 3 weeks later...

So looking through that thread again I found dlandon's post that references some added and very useful plugin developer features: http://lime-technology.com/forum/index.php?topic=31735.msg288775#msg288775.

 

Just to make sure I understand what he is saying correctly (dlandon if you find this feel free to chime in):

By using the KXX.sh and SXX.sh files he is talking about I can mount and unmount my sshfs mounts when the array is being stopped (but only when powerdown is the process initiating the shutdown) and mount them when unRAID starts up, correct? So I would no longer need those lines in my go file as long as I keep the powerdown plugin installed?

 

I would still then need a way to mount and unmount the shares when I am starting/stopping the array from the webUI without the powerdown script being involved correct?

 

 

Edit:

 

Ok so I created the K00.sh and S00.sh files and they seem to be working fine:

-When I start the array (after having previously stopped the array) my remote mounts are created just fine.

-When I stop the array they are removed fine.

-When I power off the machine they are removed just fine.

 

The one thing I am still having issues with is getting them to mount when I first start the server. I first tried to follow what Dreded talked about in his post here: http://lime-technology.com/forum/index.php?topic=26201.msg272564#msg272564

 

I created a script and stored it in /boot/config/plugins/sshfs/mounting and added my relevant sshfs mount commands to the file. I then created go file entries to copy the file into the appropriate directories like he did:

mkdir -p /usr/local/emhttp/plugins/sshfs/event/mount

cp /boot/config/plugins/sshfs/mounting /usr/local/emhttp/plugins/sshfs/event/mount/

chmod +x  /usr/local/emhttp/plugins/sshfs/event/mount/mounting

 

I rebooted the server and the sshfs mounts were never created. I checked the syslog and didn't see any errors mentioned regarding sshfs or the local directory I was mounting to.

 

I next tried to just put the mount commands directly into the go file which fuse didn't like. During boot I got three errors on the screen all referencing the local mount point saying:

/mnt/cache/.watch/tv-remote: no such file or directory

/mnt/cache/.watch/movies: no such file or directory

/mnt/cache/.watch/music-remote: no such file or directory

 

I guess this must be because the go file is ran before the cache disks are mounted?

 

EDIT2: Also It appears as though docker is starting before my shares are being mounted so the remote file systems aren't accessible to my docker container until I manually restart the docker service. Is there a way to make sure docker starts AFTER my sshfs shares have been mounted so I don't need to restart the service?

Bump, hoping a plugin developer (or anyone really) can help me figure out what I need to do or what I need to change to get these remote shares mounted at boot up. Is my above assumption correct that the go file is read before drives are mounted? If so is there any way I can get these mounts created automatically after the drives are mounted?

Link to comment

Not at my computer right now but I don't think mounting is a valid event.  Think you have to use start_array.  Will edit this post in a bit

 

 

EDIT:

 

within /usr/local/emhttp/plugins/sshfs/event/

 

you store the script.  The script will be named disks_mounted

 

Similarly if you want to use the same method to umount everything you create a script called stopping_svcs

 

Sent from my LG-D852 using Tapatalk

 

 

Link to comment

Not at my computer right now but I don't think mounting is a valid event.  Think you have to use start_array.  Will edit this post in a bit

 

 

EDIT:

 

within /usr/local/emhttp/plugins/sshfs/event/

 

you store the script.  The script will be named disks_mounted

 

Similarly if you want to use the same method to umount everything you create a script called stopping_svcs

 

Sent from my LG-D852 using Tapatalk

Interesting so they have to have specific filenames, I can't just call them whatever I want?

 

On my test server I did a restart after updating the PowerDown plugin to dlandon's latest version  and my mounts were created at boot without me having to intervene. So its possible that the cleanup changes dlandon mentioned for his latest version resolved the issues I was having.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.