[arch-general] systemd automount + wake-on-lan dependency
I want my media pc to automatically mount several samba shares when they're accessed. In addition it also needs to wake-up the other machine if it is currently suspended via WOL.
From a forum post on xbmc.org (1) I know this can be done using autofs, but I'd like to see if this can be using systemd alone. I know systemd can handle the automounting, but what about the WOL?
Is it as simple as merely providing a dependency to the specific automount service file to first do the WOL? A oneshot unit? Or perhaps part of the same unit file with ExecStartPre (if there is such a thing in a automount file)? Any hints or tips? Thanks, Sander [1] http://forum.xbmc.org/showthread.php?tid=118164
On 01/08/2013 05:39 PM, Sander Jansen wrote:
I want my media pc to automatically mount several samba shares when they're accessed. In addition it also needs to wake-up the other machine if it is currently suspended via WOL.
From a forum post on xbmc.org (1) I know this can be done using autofs, but I'd like to see if this can be using systemd alone. I know systemd can handle the automounting, but what about the WOL?
Is it as simple as merely providing a dependency to the specific automount service file to first do the WOL? A oneshot unit? Or perhaps part of the same unit file with ExecStartPre (if there is such a thing in a automount file)?
Any hints or tips?
Thanks,
Sander
[1] http://forum.xbmc.org/showthread.php?tid=118164 Might be simpler to set up your wol servers with "ethtool -s ethX wol u" to wake on unicast messages.
On Tue, Jan 8, 2013 at 8:01 PM, Ashim Acharya <ashimtron@gmail.com> wrote:
I want my media pc to automatically mount several samba shares when
On 01/08/2013 05:39 PM, Sander Jansen wrote: they're
accessed. In addition it also needs to wake-up the other machine if it is currently suspended via WOL.
From a forum post on xbmc.org (1) I know this can be done using autofs, but I'd like to see if this can be using systemd alone. I know systemd can handle the automounting, but what about the WOL?
Is it as simple as merely providing a dependency to the specific automount service file to first do the WOL? A oneshot unit? Or perhaps part of the same unit file with ExecStartPre (if there is such a thing in a automount file)?
Any hints or tips?
Thanks,
Sander
[1] http://forum.xbmc.org/showthread.php?tid=118164 Might be simpler to set up your wol servers with "ethtool -s ethX wol u" to wake on unicast messages.
That might be a good idea. I assume the mere attempt to mount / connect to the server would wake it up. I guess the only downside that any other attemps to connect would wake up the machine as well. As opposed to a more controlled way using the magic packet. Sander
On Tue, Jan 8, 2013 at 8:01 PM, Ashim Acharya <ashimtron@gmail.com> wrote:
I want my media pc to automatically mount several samba shares when
On 01/08/2013 05:39 PM, Sander Jansen wrote: they're
accessed. In addition it also needs to wake-up the other machine if it is currently suspended via WOL.
From a forum post on xbmc.org (1) I know this can be done using autofs, but I'd like to see if this can be using systemd alone. I know systemd can handle the automounting, but what about the WOL?
Is it as simple as merely providing a dependency to the specific automount service file to first do the WOL? A oneshot unit? Or perhaps part of the same unit file with ExecStartPre (if there is such a thing in a automount file)?
Any hints or tips?
Thanks,
Sander
[1] http://forum.xbmc.org/showthread.php?tid=118164 Might be simpler to set up your wol servers with "ethtool -s ethX wol u" to wake on unicast messages.
Ok. Bad news is that "u" will break the suspend/resume on my box for some reason. It suspends fine, but once resuming, it gets stuck in a suspend / resume loop where it will wake up for a second before turning off again (rinse and repeat). Good news was that I was able to get a systemd share.mount unit working with a wol.service unit. Starting the mount unit will correctly start the wol.service unit and wake the machine using the magic packet. What I haven't got working is the automount: So far it only tries to mount the share, but not activate the wol.service unit. Perhaps the automount units also needs to depend on the wol.service? Sander
I want my media pc to automatically mount several samba shares when
On 01/08/2013 05:39 PM, Sander Jansen wrote: they're
accessed.
Is that even possible? Because the way Samba protocol works it might be some time (as much as some good 10 minutes, may be a little more) until the shares are up and ready to be accessed on the network. This is not the case with NFSv4 in which case AutoFS will find and mount instantly any share providing the NFS server is up, of course. OTOH if the NFS server is down when you try to access it via AutoFS the NFS client on your machine will initiate the Stall of Death, but that's another song :p
Good news was that I was able to get a systemd share.mount unit working with a wol.service unit. Starting the mount unit will correctly start the wol.service unit and wake the machine using the magic packet. What I haven't got working is the automount: So far it only tries to mount the share, but not activate the wol.service unit. Perhaps the automount units also needs to depend on the wol.service?
Sander
Since I'm migrating my network shares everywhere from NFS to Samba (the later being slower but more reliable) I'm most interested in the work you've done, can you post the units back? Regards.
On Thu, Jan 10, 2013 at 6:38 AM, Martín Cigorraga <msx@archlinux.us> wrote:
I want my media pc to automatically mount several samba shares when
On 01/08/2013 05:39 PM, Sander Jansen wrote: they're
accessed.
Is that even possible? Because the way Samba protocol works it might be some time (as much as some good 10 minutes, may be a little more) until the shares are up and ready to be accessed on the network. This is not the case with NFSv4 in which case AutoFS will find and mount instantly any share providing the NFS server is up, of course. OTOH if the NFS server is down when you try to access it via AutoFS the NFS client on your machine will initiate the Stall of Death, but that's another song :p
I don't know. For me it works pretty quickly. Haven't noticed any giant delays.
Good news was that I was able to get a systemd share.mount unit working with a wol.service unit. Starting the mount unit will correctly start the wol.service unit and wake the machine using the magic packet. What I haven't got working is the automount: So far it only tries to mount the share, but not activate the wol.service unit. Perhaps the automount units also needs to depend on the wol.service?
Sander
Since I'm migrating my network shares everywhere from NFS to Samba (the later being slower but more reliable) I'm most interested in the work you've done, can you post the units back?
I'm still suffering from the suspend/problem I mentioned before (although not all the time), but so far I have the following units files and as long my computer resumes fine, it all seems to work: wol-anathem.service: --------------------------- [Unit] Description=Wake-on-Lan Anathem Requires=network.target [Service] ExecStart=/usr/bin/wol MACADDRESS Type=oneshot mnt-anathem.mount: --------------------------- [Mount] What=//ANATHEM/mysharename Where=/mnt/anathem Type=cifs Options=ip=192.168.1.42,sec=none [Unit] Requires=wol-anathem.service After=wol-anathem.service mnt-anathem.automount: --------------------------- [Automount] Where=/mnt/anathem [Unit] Requires=wol-anathem.service After=wol-anathem.service
Thank you! I'm gonna try these right now :) BTW since you're working with Samba, do you know about SMBNetFS? It's very flexible and works quite good here. https://www.archlinux.org/packages/?q=smbnetfs On Sat, Jan 12, 2013 at 10:55 PM, Sander Jansen <s.jansen@gmail.com> wrote:
participants (3)
-
Ashim Acharya
-
Martín Cigorraga
-
Sander Jansen