Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
autofs failing to mount sshfs - is autofs rotting?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3347
Location: Rasi, Finland

PostPosted: Fri Apr 24, 2020 8:35 am    Post subject: autofs failing to mount sshfs - is autofs rotting? Reply with quote

Code:
*  net-fs/autofs                                                                                         
      Latest version available: 5.1.6                                                                   
      Latest version installed: 5.1.5-r2                                                                 
      Size of files: 308 KiB                                                                             
      Homepage:      https://web.archive.org/web/*/http://www.linux-consulting.com/Amd_AutoFS/autofs.html
      Description:   Kernel based automounter                                                           
      License:       GPL-2                                                                               
... the homepage points to wayback machine.

The problem is that autofs passes -n -switch, which is not understood by fuse. There is already a bug raised for autofs, but with other than sshfs.

Are there alternatives for autofs for OpenRC based systems? I wouldn't want to start transitioning to systemd now... Besides I've always thought autofs is unnecessary complicated for a such simple tool that mounts filesystems on-demand.
If I were to implement such thing (for which I don't have proper skills, unfortunately), I'd probably would just have it read a single fstab like file (or file.d for a directory of several files). Timeouts defined in seperate columns or in -o options,umount_timeout=X -format.

And yes: I've also tried the latest version of autofs. I just tried to downgrade it to see if the problem exists with the older version too.
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3140

PostPosted: Fri Apr 24, 2020 11:29 am    Post subject: Reply with quote

Quote:
Are there alternatives for autofs for OpenRC based systems? I wouldn't want to start transitioning to systemd now

You can mount sshfs with /etc/fstab line. What feature does autofs provide you which requires this particular tool? I'm not familiar with it, although I do know it exists.
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2720

PostPosted: Fri Apr 24, 2020 11:51 am    Post subject: Reply with quote

szatox wrote:
You can mount sshfs with /etc/fstab line. What feature does autofs provide you which requires this particular tool? I'm not familiar with it, although I do know it exists.
I don't use it but as far as I know it'd auto-mount when you attempt to access the directory rather than keep it always mounted (aka on-demand), which saves you from opening connections persistently for nothing, or need you to manually mount.

Rather than bother personally I do keep persistent mounts with /etc/fstab and openrc's netmount for sshfs (+some auto-reconnect settings so I can bring remote machine down/up and keep things mounted), but well, that's a different approach and I'm not familiar with autofs/alternatives.
Edit: although normal mount command should work if you have a proper /etc/fstab line and some automounter shouldn't need to call mount.fuse directly at all.. not that I know how it handles things
Back to top
View user's profile Send private message
cz0
Apprentice
Apprentice


Joined: 13 Jun 2005
Posts: 280
Location: /earth/russia/moscow

PostPosted: Fri Apr 24, 2020 3:22 pm    Post subject: Reply with quote

szatox wrote:
Quote:
Are there alternatives for autofs for OpenRC based systems? I wouldn't want to start transitioning to systemd now

You can mount sshfs with /etc/fstab line. What feature does autofs provide you which requires this particular tool? I'm not familiar with it, although I do know it exists.

Not anymore.
Code:

host:/path/files /home/user/path fuse.sshfs noauto,user,nonempty,_netdev,idmap=user,default_permissions,uid=1000,gid=1000 0 0

Fails now, while it used to work some time ago.
Back to top
View user's profile Send private message
Ionen
Developer
Developer


Joined: 06 Dec 2018
Posts: 2720

PostPosted: Fri Apr 24, 2020 3:26 pm    Post subject: Reply with quote

cz0 wrote:
Not anymore.
My sshfs lines in fstab looks like
Code:
user@host:/remote/dir /local/dir sshfs _netdev,ro,uid=myuser,gid=mygroup,allow_other,reconnect,idmap=user,transform_symlinks,\
ServerAliveInterval=15,ServerAliveCountMax=3,IdentityFile=/path/to/id_rsa,UserKnownHostsFile=/path/to/known_hosts 0 0
and work just fine. I can go and run "mount /local/dir" and it's mounted, or let openrc mount it without noauto since I normally never mount manually.

This is with fuse3, I did experience some breakage a while back when I moved away from fuse2 that needed me to update fstab.. but I was using ancient deprecated sshfs# syntax.

Edit: added full (broken in half) fstab line instead of cropping it, settings could probably be better.. haven't reviewed those in a while.


Last edited by Ionen on Fri Apr 24, 2020 4:23 pm; edited 1 time in total
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3347
Location: Rasi, Finland

PostPosted: Fri Apr 24, 2020 4:23 pm    Post subject: Reply with quote

Yes. autofs is an on-demand mounter.

Need it because I have some devices (laptop, mobile phone) that are not always in the same network. I also have accees to a server where I keep few web pages etc where it's most effortless just to mount the files with sftp. I also push some backups there via rsync. But I surely don't want to keep the connection open all the time.

I have udisks on my system... I wonder if I could achieve same functionality with it via some tool?
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3140

PostPosted: Sat Apr 25, 2020 8:35 am    Post subject: Reply with quote

Ok, so, how 'bout /etc/fstab line with additional options like user,noauto?
Depending on your DE you may be able to mount it transparently by entering that mountpoint.
Also, the simple trick with mount /path/to/mountpoint will work regardless of DE in use and does not require you remember all the options.

Is is there something else about autofs like checking for pre-conditions and mounting external resouces based on that instead of relaying on an invocation by the user?
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3347
Location: Rasi, Finland

PostPosted: Sun Apr 26, 2020 8:42 am    Post subject: Reply with quote

szatox wrote:
Ok, so, how 'bout /etc/fstab line with additional options like user,noauto?
Depending on your DE you may be able to mount it transparently by entering that mountpoint.
If only that worked when cd'ing into the said directory.
I have all my photos on my server and my photo editors/manages need to be able to access the shares.

But yes, user,noauto is simple and I do like it.
Question: If I do that, can all the users mount these network filesystems? I assume not if the filesystem is in my home directory and permissions are set correctly.

I wonder if I could combine user,noauto mount and some inotify trick to make them automount without autofs... The tricky part would be to set some kind of timeout.

In the end I think OpenRC needs a on-demand-netmount service (as a subproject). ;)

szatox wrote:
Is is there something else about autofs like checking for pre-conditions and mounting external resouces based on that instead of relaying on an invocation by the user?
Not that I know of. I think autofs only mounts the fs if any program tries to access it. Although autofs has tons of options in the config file...
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3140

PostPosted: Sun Apr 26, 2020 7:38 pm    Post subject: Reply with quote

Quote:
Question: If I do that, can all the users mount these network filesystems? I assume not if the filesystem is in my home directory and permissions are set correctly.
I think that you need write permission on the mountpoint to be able to mount it.

Quote:
If only that worked when cd'ing into the said directory.
This is a tricky one.
You can track file_open event with inotify, but I think you will enter the directory first and THEN mount your network share on top of that. Which means you will see the contents of the underlying directory rather than then your network share, until you "cd ."
Back to top
View user's profile Send private message
sveyret
n00b
n00b


Joined: 27 Oct 2016
Posts: 24

PostPosted: Wed Apr 29, 2020 7:47 am    Post subject: Reply with quote

Zucca wrote:
If only that worked when cd'ing into the said directory.

Maybe you could be interested in a tool I made a few years ago: https://github.com/sveyret/magicd/
There is no entry for an automount, but this should be rather easy to create. If you want to use it and need some help, do not hesitate and ask me.
(Note that there is an ebuild for it in my overlay: https://github.com/sveyret/sveyret-overlay)
_________________
Stéphane
Gentoo in the Alps…
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3140

PostPosted: Fri May 08, 2020 9:27 am    Post subject: Reply with quote

Actually, if you only need it for text console, you can use an alias that would check if there is anything to mount, mount it, and then cd into that directory. Seems easy enough to do.
Obviously, providing this functionality for other programs wouldn't be that easy. Chances are it would require patching some libs (libc?) to let you hijach a system call to open a file. And running this test for every single file open could really slow down your system.
Back to top
View user's profile Send private message
Logicien
Veteran
Veteran


Joined: 16 Sep 2005
Posts: 1555
Location: Montréal

PostPosted: Fri May 08, 2020 12:14 pm    Post subject: Reply with quote

I use autofs since many years on different Linux distributions. What I do is to comment all the lines in /etc/autofs/auto.master and only give the path to a subdirectory file where all the mount points are defines with all options
Code:
/- /etc/autofs/auto.autofs


In the /etc/autofs/auto.autofs file I have many lines to automount the root directory of Linux on other machine of my local wireless network. I automount my cdrom cd in there too
Code:
/media/asus     -fstype=cifs,_netdev,nofail,noserverino,password=,port=445,ro,vers=3.0 ://ASUS/Racine
/media/cdrom    -fstype=auto,nodev,noexec,nofail,nosuid,ro                             :/dev/sr0

There is two files to configure, one is /etc/default/autofs in which there is only one none commented line who ask if I want to use misc device what I set to no
Code:
USE_MISC_DEVICE="no"

The other one is /etc/autofs/autofs.conf. I give the uncommented lines that I use
Code:
[ autofs ]
master_map_name = auto.master
timeout = 30
master_wait = 10
negative_timeout = 10
mount_verbose = no
mount_wait = 10
umount_wait = 10
browse_mode = yes

As you can see the timeout to automount and autounmount are set there so I do not have to pass those options somewhere else. The two configure files can be somewhere else depending on the distribution. So, if you configure the subdirectory file (/etc/autofs/auto.autofs here) well with precise options, is mount will use none desires options? You have to check.
_________________
Paul
Back to top
View user's profile Send private message
Zucca
Moderator
Moderator


Joined: 14 Jun 2007
Posts: 3347
Location: Rasi, Finland

PostPosted: Fri May 15, 2020 10:53 am    Post subject: Reply with quote

@Logicien: I've been using almost the exact same configuration as you from the beginning. The problem is autofs (or rather automount) passing the -n switch to fuse mounts. I think the problem started when I updated kernel... which is strange.

Also /etc/default/autofs is absent on my system. (Why the hell some programs do put their configuration there anyways? It seems to me like having another etc under /etc.)

I do have /etc/conf.d/autofs, from where I can try to solve this problem.
_________________
..: Zucca :..
Gentoo IRC channels reside on Libera.Chat.
--
Quote:
I am NaN! I am a man!
Back to top
View user's profile Send private message
shredator
Tux's lil' helper
Tux's lil' helper


Joined: 14 Apr 2005
Posts: 82

PostPosted: Sun Oct 24, 2021 3:33 am    Post subject: Reply with quote

I'm having this same problem too. Anyone figure out how to have mount not pass the -n?

Also, I see that it is passing the -n because /etc/mtab is a link and not a file. If I delete the mtab link and just copy /proc/self/mounts to /etc/mtab, things work fine. But that only works until the next reboot.

I dont really know what all relies on mtab... would there be major breakage by changing the mtab init script to just copy instead of link?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21644

PostPosted: Sun Oct 24, 2021 4:36 am    Post subject: Reply with quote

/etc/mtab is normally a link to /proc/self/mounts because that is the only way to keep it accurate in the general case. With mount namespaces, different processes can have different ideas of what is currently mounted, but they would by default share the same /etc/mtab.

Based on reading the autofs source, it automatically enables -n when /etc/mtab is a symlink to /proc/mounts or /proc/self/mounts. Presumably this means that if the link pointed to /proc/self/../mounts, then autofs would not enable passing -n. However, omitting -n may break for mounting filesystems that otherwise update mtab. I think you would be better served either fixing FUSE to accept -n, or changing autofs to have a specific option that inhibits -n, so that you can suppress it on a per-mount basis.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum