Page 6 of 14 FirstFirst ... 45678 ... LastLast
Results 51 to 60 of 139

Thread: SSHFS AUTOmount on Feisty

  1. #51
    Join Date
    Aug 2007
    Beans
    13

    Lightbulb Re: SSHFS AUTOmount on Feisty

    I found your guide very useful, and appreciated the fact that your solution conformed to debian/ubuntu standards (many don't).

    I have found that in Hardy Heron, /etc/mtab sees fuse mounted sshfs mounts as being type "fush.sshfs". Since we have to define them of type "fuse" in /etc/fstab, the two don't match, and "umount" does not work. I can only unmount these drives with "fusermount -u" or "fusermount -u -z". Also, these mounts do not show "sshfs#" at the beginning of each sshfs mounted drive.

    Based on these two items, I modified my version of /etc/network/if-down.d/umountsshfs to end with these two lines:
    Code:
    mounted=`grep 'fuse.sshfs' /etc/mtab | awk '{ print $2 }'`
    [ -n "$mounted" ] && { for mount in $mounted; do fusermount -u -z $mount; done; }
    I am not fond of the differences between /etc/fstab and /etc/mtab. They are probably actually a bug in the sshfs or fuse code. I'm tempted to create add some lines to /etc/network/if-up.d/mountsshfs (after a successful mount) AND /etc/network/if-down.d/umountsshfs (before an attempt to unmount) to use sed to change the "fuse.sshfs" lines to match the /etc/fstab lines using "sshfs#" and "fuse". I really think that a fuse.sshfs wrapper might be needed, but I have no idea what should be in it.

    This line will modify /etc/mtab, but requires su rights, so it defeats part of the purpose of this (suggestions are appreciated):
    Code:
    sudo sed 's/\(^[^@]\{1,\}@\)\(.\{1,\}\) fuse\.sshfs /sshfs#\1\2 fuse /' -i /etc/mtab
    The line above is effective in making umount work correctly, but it does not change the fact that it requires su rights to run. I'm filed the differences between fstab and mtab as a bug#243298 on launchpad (https://bugs.launchpad.net/ubuntu/+s...se/+bug/243298).
    Last edited by chriv; June 26th, 2008 at 06:31 PM. Reason: Linked to launchpad bug

  2. #52
    Join Date
    Feb 2007
    Beans
    77

    Re: SSHFS AUTOmount on Feisty

    Quote Originally Posted by dittaeva View Post
    Two zeroes "0 0" are needed in the end of the fstab entry in the tutorial, they are missing and needed.

    Those familiar with fstab will remember to add them, but for those who follow the guide blindly it will pose a problem, at least it did for me in Ubuntu 8.10.
    Thank you, I fixed it.


    I'd also like to note that the script still works unmodified in Hardy, except for the problem, already mentioned, that you must use fusermount -u instead of umount. Despite this, I find that the auto-unmount script (which uses umount) still works fine, since it unmounts everything with administrator (root) privileges. I will file a bug in the Ubuntu bug-tracking system for this.

    If possible, I would like to work out how to use the GNOME gvfs system to replace sshfs, since that should integrate better with the file manager. If I succeed, I will post a link in this thread.

  3. #53
    Join Date
    Feb 2007
    Beans
    77

    Re: SSHFS AUTOmount on Feisty

    Quote Originally Posted by Darwin Award Winner View Post
    If possible, I would like to work out how to use the GNOME gvfs system to replace sshfs.
    After some preliminary tests, I'm convinced that this is possible. However, I cannot work on it right now, because the sftp transport of gvfs is unable to connect to one of my servers.

  4. #54
    Join Date
    Feb 2007
    Location
    New York
    Beans
    894
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: SSHFS AUTOmount on Feisty

    Quote Originally Posted by Darwin Award Winner View Post
    You should have a pair of directories called /etc/network/if-up.d and /etc/network/if-down.d.

    Scripts in the first directory will be executed when the computer connects to the network, and scripts in the second one will be executes when it disconnects.
    Does this work if the ssh server is the thing going up and down, though? If I'm trying to have a remote machine mount directories on my laptop, and I shut down the laptop, what will happen? This script is running on the remote server, so its own network connection will still be up.

    Quote Originally Posted by Darwin Award Winner View Post
    If you're looking for a GUI way, you should probably wait until Hardy Heron comes out, featuring the new GVFS system from Gnome, which does let you mount virtual filesystems in the real filesystem.
    I waited, and GVFS still doesn't do what I want. In this case, when you first log into a server through the Places GUI, a link is created in ~/.gvfs, which is what I was hoping for, but this link does not exist in the future, even if you connect to the same location through Nautilus or the Places list. ~/.gvfs is just empty. I was expecting the link to be persistent, and to open up an SSH connection whenever accessed.

    Also, since GVFS is user-based, it doesn't work for a remote server connecting to the thing you are logged into (In my case, a media player that accesses the music directory on my laptop.)
    "Please remember to do things the Ubuntu way. There is always more than one solution to a problem, choose the one you think will be the easiest for the user. ... Try to think as a green user and choose the simplest solution." — Code of Conduct

  5. #55
    Join Date
    Feb 2007
    Beans
    77

    Re: SSHFS AUTOmount on Feisty

    Endolith, you're right, this is a client-side solution. It basically assumes that all the servers will always be up.

    However, as for GVFS, there's a command called gvfs-mount which could be used in a script to automount locations in the same way as my script, so my script could easily be rewritten to use GVFS. (The only problem for me is that it has trouble connectign to one of the servers I use, since that server doesn't use openssh.) That still doesn't serve your problem, though.

    To solve your problem, I can think of another solution using ssh and sshfs. First, you'd need to set up passwordless logins going both ways (i.e. set it up so you can ssh from laptop to server and server to laptop). Then, on the laptop, in /etc/network/if-up.d/, you would put a script that runs a command something like this:

    Code:
    #!/bin/sh
    sudo -u username ssh myserver '{ fusermount -uz ~/musicfolder; sshfs username@mylaptop:~/musicfolder ~/musicfolder; }'

  6. #56
    Join Date
    Feb 2007
    Location
    New York
    Beans
    894
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: SSHFS AUTOmount on Feisty

    Quote Originally Posted by Darwin Award Winner View Post
    However, as for GVFS, there's a command called gvfs-mount which could be used in a script to automount locations in the same way as my script, so my script could easily be rewritten to use GVFS. (The only problem for me is that it has trouble connectign to one of the servers I use, since that server doesn't use openssh.) That still doesn't serve your problem, though.
    Oh, I see. That's in gvfs-bin, which I didn't have installed. Still don't see documentation for it, though.

    To solve your problem, I can think of another solution using ssh and sshfs. First, you'd need to set up passwordless logins going both ways (i.e. set it up so you can ssh from laptop to server and server to laptop).
    Already did that. http://ubuntuforums.org/showthread.php?p=5339039

    Then, on the laptop, in /etc/network/if-up.d/, you would put a script that runs a command something like this:

    Code:
    #!/bin/sh
    sudo -u username ssh myserver '{ fusermount -uz ~/musicfolder; sshfs username@mylaptop:~/musicfolder ~/musicfolder; }'
    Aha! That's basically what I've been typing by hand, except you put it in a script that gets run whenever the network comes up. Suddenly everything makes a lot more sense to me.

    I notice there are (possibly redundant https://bugs.launchpad.net/ubuntu/+s...it/+bug/228150) scripts in if-up.d that mount all the network file systems defined in fstab. Apparently this does not include sshfs, which is why you created your mountsshfs script?

    Maybe it would be easier to set this up, and more robust, if we got sshfs added to the default scripts, and then defined the sshfs shares in fstab, and then had my laptop script simply call the mountnfs script on the other machine through ssh? Then the shares would connect whenever both machines were online, regardless of which machine turned off and back on?


    Also, you should put a comment in your scripts with this thread's URL, so it's easy to remember where they came from when some configuration change breaks them 3 years from now.
    Last edited by Endolith; July 9th, 2008 at 10:47 AM.
    "Please remember to do things the Ubuntu way. There is always more than one solution to a problem, choose the one you think will be the easiest for the user. ... Try to think as a green user and choose the simplest solution." — Code of Conduct

  7. #57
    Join Date
    Feb 2007
    Beans
    77

    Re: SSHFS AUTOmount on Feisty

    Quote Originally Posted by Endolith View Post
    Maybe it would be easier to set this up, and more robust, if we got sshfs added to the default scripts, and then defined the sshfs shares in fstab, and then had my laptop script simply call the mountnfs script on the other machine through ssh? Then the shares would connect whenever both machines were online, regardless of which machine turned off and back on?
    The mountnfs scripts make the same assumption that my script does, i.e. that the servers that it connects to are always on (you could call this the client assumption), so there's nothing about those scripts that would guarantee that the shares were mounted whenever both ends were on. I seem to recall someone else's solution which included a script that pinged all the servers every 5 minutes or so and mounted or unmounted the shares based on whether the ping succeeded. You could try searching for that.

    As for integration of sshfs into those scripts, I suppose it would be possible. It gets complicated, though, since you have to put "fuse" as the filesystem type in /etc/fstab, which obviously does not indicate an sshfs mount.

    Also, you should put a comment in your scripts with this thread's URL, so it's easy to remember where they came from when some configuration change breaks them 3 years from now.
    Done.

  8. #58
    Join Date
    Feb 2007
    Location
    New York
    Beans
    894
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: SSHFS AUTOmount on Feisty

    Quote Originally Posted by Darwin Award Winner View Post
    The mountnfs scripts make the same assumption that my script does, i.e. that the servers that it connects to are always on (you could call this the client assumption), so there's nothing about those scripts that would guarantee that the shares were mounted whenever both ends were on.
    I meant that building sshfs into the network shares script would simplify things for both use cases. I would still be calling the other computer's scripts through SSH, but I'd just tell it to run its own if-up script instead of mounting the shares explicitly. Having it defined in the server's fstab would ensure that it was mounted when the server reboots, too, right?

    I set up your explicit script and it seems to work. Thanks!

    As for integration of sshfs into those scripts, I suppose it would be possible. It gets complicated, though, since you have to put "fuse" as the filesystem type in /etc/fstab, which obviously does not indicate an sshfs mount.
    Ah..
    "Please remember to do things the Ubuntu way. There is always more than one solution to a problem, choose the one you think will be the easiest for the user. ... Try to think as a green user and choose the simplest solution." — Code of Conduct

  9. #59
    Join Date
    Feb 2007
    Location
    New York
    Beans
    894
    Distro
    Ubuntu 9.10 Karmic Koala

    Re: SSHFS AUTOmount on Feisty

    Quote Originally Posted by Darwin Award Winner View Post
    The mountnfs scripts make the same assumption that my script does, i.e. that the servers that it connects to are always on (you could call this the client assumption), so there's nothing about those scripts that would guarantee that the shares were mounted whenever both ends were on.
    Here's what I have for now:

    Server /etc/network/if-up.d/sshfsmount:
    Code:
    #!/bin/bash
    
    fusermount -uz "/home/serverusername/Music/Remote CD-ROM/"
    sshfs username@laptophostname:"/media/cdrom" "/home/serverusername/Music/Remote CD-ROM"
    
    fusermount -uz "/home/serverusername/Music/Remote My Music"
    sshfs username@laptophostname:"/media/windows/Documents and Settings/Username/My Documents/My Music" "/home/serverusername/Music/Remote My Music"
    
    fusermount -uz "/home/serverusername/Music/FTP music/"
    sshfs username@laptophostname:"/home/ftp" "/home/serverusername/Music/FTP music"
    Laptop /etc/network/if-up.d/sshfsmount:
    Code:
    #!/bin/bash
    
    sudo -u username ssh serverhostname '
    bash /etc/network/if-up.d/sshfsmount
    '
    That way if the server comes up and the laptop is already on, it mounts the laptop's shares. If the laptop comes up and the server is already up, it asks the server to mount the shares, and I only have to edit the shares list in one place.

    I seem to recall someone else's solution which included a script that pinged all the servers every 5 minutes or so and mounted or unmounted the shares based on whether the ping succeeded. You could try searching for that.
    That's a good idea. I can't find it, though.
    "Please remember to do things the Ubuntu way. There is always more than one solution to a problem, choose the one you think will be the easiest for the user. ... Try to think as a green user and choose the simplest solution." — Code of Conduct

  10. #60
    Join Date
    Jun 2008
    Beans
    2

    Re: SSHFS AUTOmount on Feisty

    "As an added bonus, since these shares are in fstab, GNOME will automatically create desktop icons for them when they are mounted, so you will have easy access to them."

    I have yet to see these desktop icons appear, any settings I have to change to make it happen?

Page 6 of 14 FirstFirst ... 45678 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •