Re: [Nix-dev] systemd + sshfs

2016-09-19 Thread Bjørn Forsman
One problem remains. When the network is down, the generated mount
unit (which systemd creates from parsing /etc/fstab) can easily enter
failed state after a few failed mounts. And due to automatic
dependencies, the automount unit becomes failed too. This is the
problem. Without the automount service, the sshfs mountpoint is left
all empty and a manual step is needed to fix the situation.

I think what's need is a Restart=always or something for one of those
units. The problem is that such options are not available in the
/etc/fstab interface[1].

So I'm back to the issue from the first post: how to mount sshfs using
the systemd.mount interface (which has full access to Restart= etc.
directives)?

In general: why is it so difficult to have a mountpoint that either
gives you access to the other filesystem OR returns an error? It seems
all too easy to end up in a situation where the filesystem becomes
"silently" unmounted and programs accessing the mountpoint will not
know about it (happily continuing using the now local filesystem).
Non-solutions: using mountpoint(1) or "test
mountpoint/THIS_FILE_INDICATES_NOT_MOUNTED".

Best regards,
Bjørn Forsman

[1] Systemd parses a few special options from /etc/fstab:
https://www.freedesktop.org/software/systemd/man/systemd.mount.html#fstab
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] systemd + sshfs

2016-09-19 Thread Bjørn Forsman
On 19 September 2016 at 15:04, Bjørn Forsman  wrote:
> [...] but GVFS really doesn't want to leave autofs filesystems alone.
> It constantly tries to mount/activate them. And if the filesystem
> cannot be mounted (network down) the systemd unit enters failed state
> and users see will see the empty mountpoint directory without any
> warning. Bad.

I asked on the GVFS mailing list and got tip about using "x-gvfs-hide"
mount option. That did it, gvfs no longer automounts the autofs mounts
:-)

Best regards,
Bjørn Forsman
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] systemd + sshfs

2016-09-19 Thread Bjørn Forsman
Hi Rickard,

On 18 September 2016 at 23:19, Rickard Nilsson
 wrote:
> Hi Bjørn,
>
> I remember struggling with this too. The following works for me:
>
> fileSystems."/target" =
>   fsType = "fuse";
>   device = "${pkgs.sshfsFuse}/bin/sshfs#user@host:/path";
>   options = [
> "noauto" "comment=systemd.automount"
> "ssh_command=${sshAsUser}"
>   ];
> };
>
> where
>
>   sshAsUser = user:
> writeScript "ssh_as_${user}" ''
>   exec ${pkgs.sudo}/bin/sudo -i -u ${user} \
> ${pkgs.openssh}/bin/ssh $@
> '';
>
> The "sshAsUser" command makes systemd use my gpg-agent session correctly
> when auto-mounting. But I guess you could use it to set any ssh options
> you'd like.

Thanks, that worked!

I get a bad feeling that it has to be done this way though (if this is
the _only_ way). Shouldn't it be a way to tell systemd about 'sshfs'?

Btw, I'm still struggling to get proper "lazy" mounts that (1) detect
failure in reasonable time and (2) never silently unmount the
filesystem, even for a second. Lazy mount means I cannot use the sshfs
'reconnect' option, because that causes an ever lasting (re)connect
loop. Autofs looks like the solution (which is what the above config
uses), but GVFS really doesn't want to leave autofs filesystems alone.
It constantly tries to mount/activate them. And if the filesystem
cannot be mounted (network down) the systemd unit enters failed state
and users see will see the empty mountpoint directory without any
warning. Bad.

Here are my options so far:

  options = [
"noauto" "_netdev" "allow_other" "x-systemd.automount" #"reconnect"
"ServerAliveInterval=5" "ServerAliveCountMax=1"
"ssh_command=${sshAsUser user}"
  ];

Best regards,
Bjørn Forsman
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


Re: [Nix-dev] systemd + sshfs

2016-09-18 Thread Rickard Nilsson

Hi Bjørn,

I remember struggling with this too. The following works for me:

fileSystems."/target" =
  fsType = "fuse";
  device = "${pkgs.sshfsFuse}/bin/sshfs#user@host:/path";
  options = [
"noauto" "comment=systemd.automount"
"ssh_command=${sshAsUser}"
  ];
};

where

  sshAsUser = user:
writeScript "ssh_as_${user}" ''
  exec ${pkgs.sudo}/bin/sudo -i -u ${user} \
${pkgs.openssh}/bin/ssh $@
'';

The "sshAsUser" command makes systemd use my gpg-agent session correctly 
when auto-mounting. But I guess you could use it to set any ssh options 
you'd like.


  / Rickard

On 09/18/2016 06:10 PM, Bjørn Forsman wrote:

Hi all,

I cannot get systemd to find the 'sshfs' binary needed to make this
configuration work:

  systemd.mounts = [
{ what = "bfo@whitetip.local:/";
  where = "/home/bfo/mnt/whitetip.local";
  type = "fuse.sshfs";
  options =
"_netdev,users,idmap=user,IdentityFile=/home/user/.ssh/id_rsa,allow_other,reconnect";
  unitConfig.Environment = "PATH=${pkgs.sshfsFuse}/bin";
}
  ];

The result is "/bin/sh: sshfs: command not found", as can be seen
below my signature.

Any suggestions?



___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev