Re: [Nix-dev] systemd + sshfs
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
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
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
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
[Nix-dev] systemd + sshfs
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? -- Best regards, Bjørn Forsman $ systemctl status home-bfo-mnt-whitetip.local.mount ● home-bfo-mnt-whitetip.local.mount - /home/bfo/mnt/whitetip.local Loaded: loaded (/nix/store/9skv7lzma7gh7cc74jmf9r3jy2rw8l32-unit-home-bfo-mnt-whitetip.local.mount/home-bfo-mnt-whitetip.local.mount; bad; vendor preset: enabled) Active: failed (Result: exit-code) since sø. 2016-09-18 18:02:09 CEST; 7s ago Where: /home/bfo/mnt/whitetip.local What: bfo@whitetip.local:/ Process: 28267 ExecMount=/nix/store/42fysnk7hsi5hkyk133w3qk0rc7mmi92-util-linux-2.28.1-bin/bin/mount bfo@whitetip.local:/ /home/bfo/mnt/whitetip.local -t fuse.sshfs -o _netdev,users,idmap=user,IdentityFile=/home/user/.ssh/id_rsa,allow_other,reconnect sep. 18 18:02:09 mini systemd[1]: Mounting /home/bfo/mnt/whitetip.local... sep. 18 18:02:09 mini mount[28267]: /bin/sh: sshfs: command not found sep. 18 18:02:09 mini systemd[1]: home-bfo-mnt-whitetip.local.mount: Mount process exited, code=exited status=127 sep. 18 18:02:09 mini systemd[1]: Failed to mount /home/bfo/mnt/whitetip.local. sep. 18 18:02:09 mini systemd[1]: home-bfo-mnt-whitetip.local.mount: Unit entered failed state. $ systemctl cat home-bfo-mnt-whitetip.local.mount # /nix/store/9skv7lzma7gh7cc74jmf9r3jy2rw8l32-unit-home-bfo-mnt-whitetip.local.mount/home-bfo-mnt-whitetip.local.mount [Unit] Environment=PATH=/nix/store/6rwfz93iiax88a7x9nk9wm0lqzca6gjq-sshfs-fuse-2.7/bin [Mount] Options=_netdev,users,idmap=user,IdentityFile=/home/user/.ssh/id_rsa,allow_other,reconnect Type=fuse.sshfs What=bfo@whitetip.local:/ Where=/home/bfo/mnt/whitetip.local ___ nix-dev mailing list nix-dev@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev