Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am setting up a server with a constantly mounted sshfs directory. What is the best way to test the directory and reestablish the connection if it drops?
I don't think that'll work since your mountpoint is a directory. You could however grep for your mount point from the output of the mount command and see that it is in there and vi sshfs
mount
<excerpt of output from mount>
remote_user@host:/home/remote_user on /tmp/remote_user type fuse.sshfs (rw,nosuid,nodev,max_read=65536,user=local_user)
I check for broken mounts by testing for the existence of a known file in the mounted file system. You need to make sure the file does not exist if the FS is not mounted. If the test fails then you can assume the FS is not mounted.
I sshfs mount my /home from my main workstation to my laptop all the time.
Maybe I'm too simplistic, but I just
cd to /media/storage where I mount it, and
ls to see the contents.
If there's nothing there, I mount it again.
Of course, I've never really had a problem keeping it mounted.
My script to mount it is
#!/bin/bash
sshfs -o mydydnsdomain:/home/me /media/storage
cd /media/storage
ls
echo "If you see your stuff, you're in..."
That way, immediately upon mounting, I see that my stuff is there.
Or, you're looking for something that automagically checks and remounts, eh?
Well, this will be mounted on a server, so it will need to automated. However, I do not think a script should be too complicated to create. The only caveat with the script is to remember, if a connected drops, the kernel does not necessarily clear the mount from the mounted filesystem list. Accordingly, you would need to add, fusermount -u /location/of/directory before remounting it.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.