Re: [systemd-devel] Antw: [EXT] Re: successful mount starts a service - how?

2021-01-19 Thread lejeczek



On 19/01/2021 07:50, Ulrich Windl wrote:

Andrei Borzenkov  schrieb am 19.01.2021 um 06:30 in

Nachricht <3a365c71-004e-031e-4153-80c376d80...@gmail.com>:

19.01.2021 04:00, lejeczek пишет:

hi guys.

I'm fiddling with it but have run out of options/ideas.
What I would like to have is systemd starts a service when a device, in
my case a crypt-luks device, gets mounted which mount would happen by
manual 'cryptsetup open'

I am not aware that "cryptsetup open" mounts anything. I do not even see
any option to specify mount point in its invocation. Please show exact
command you are using that "mounts" encrypted container.

But it will make some device (/dev/mapper) to appear.

I'm on centos Stream with systemd 239 (239-43.el8)
OS after boot:
1)
-> $ systemctl status -l devs.mount
● devs.mount - /devs
   Loaded: loaded (/etc/fstab; generated)
   Active: inactive (dead)
    Where: /devs
 What: /dev/mapper/luks-devs
 Docs: man:fstab(5)
   man:systemd-fstab-generator(8)

Jan 19 10:24:45 swir.private.pawel systemd[1]: Dependency 
failed for /devs.
Jan 19 10:24:45 swir.private.pawel systemd[1]: devs.mount: 
Job devs.mount/start failed with result 'dependency'.

2)
-> $ cryptsetup open /dev/mapper/cl_swir-devs luks-devs
3)
-> $ systemctl status -l devs.mount
● devs.mount - /devs
   Loaded: loaded (/etc/fstab; generated)
   Active: active (mounted) since Tue 2021-01-19 10:27:09 
GMT; 48s ago

    Where: /devs
 What: /dev/mapper/luks-devs
...
In fstab:
/dev/mapper/luks-devs /devs   ext4 
context="system_u:object_r:root_t:s0",nofail,noatime,nobarrier,noatime,x-systemd.device-timeout=3s 
0 2


Crypt-luks device got mounted without me doing only no. 2. 
and which is fantastic. Here systemd wisdom does something 
which us users would do but as a result do not have to.


Now, how to "bind" a sevice to "that" so such a service 
would wait for and then auto start(but also stop when device 
is umounted)?

I've tried in such a service' unit a variations of these:

After=devs.mount
BindsTo=devs.mount
PartOf=devs.mount
RequiresMountsFor=/devs

But now I've run out of ideas.

many thanks, L


I see when that manual action takes place then systemd changes status of
a home.mount (which is in fstab) to "active" - and it's here where I
hope systemd would auto-start a service.
Is such a "simple" thing possible?
many thanks, L
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel

___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel



___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


Re: [systemd-devel] Antw: [EXT] Re: successful mount starts a service - how?

2021-01-19 Thread Mantas Mikulėnas
On Tue, Jan 19, 2021, 09:50 Ulrich Windl 
wrote:

> >>> Andrei Borzenkov  schrieb am 19.01.2021 um 06:30
> in
> Nachricht <3a365c71-004e-031e-4153-80c376d80...@gmail.com>:
> > 19.01.2021 04:00, lejeczek пишет:
> >> hi guys.
> >>
> >> I'm fiddling with it but have run out of options/ideas.
> >> What I would like to have is systemd starts a service when a device, in
> >> my case a crypt-luks device, gets mounted which mount would happen by
> >> manual 'cryptsetup open'
> >
> > I am not aware that "cryptsetup open" mounts anything. I do not even see
> > any option to specify mount point in its invocation. Please show exact
> > command you are using that "mounts" encrypted container.
>
> But it will make some device (/dev/mapper) to appear.
>

Yes, and that can be used to trigger a mount unit.

With earlier systemd versions it was actually enough to have a fstab entry
with "auto,nofail" and systemd would immediately activate such mounts as
soon as the source device appeared.

In systemd v242 this behavior was removed (and unfortunately, there is no
convenient fstab option to re-enable it), but the same type of dependency
can still be manually added using:

systemctl add-wants 'dev-mapper-luks\x2bfoo.device' foo.mount
___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel


[systemd-devel] Antw: [EXT] Re: successful mount starts a service - how?

2021-01-18 Thread Ulrich Windl
>>> Andrei Borzenkov  schrieb am 19.01.2021 um 06:30 in
Nachricht <3a365c71-004e-031e-4153-80c376d80...@gmail.com>:
> 19.01.2021 04:00, lejeczek пишет:
>> hi guys.
>> 
>> I'm fiddling with it but have run out of options/ideas.
>> What I would like to have is systemd starts a service when a device, in
>> my case a crypt-luks device, gets mounted which mount would happen by
>> manual 'cryptsetup open'
> 
> I am not aware that "cryptsetup open" mounts anything. I do not even see
> any option to specify mount point in its invocation. Please show exact
> command you are using that "mounts" encrypted container.

But it will make some device (/dev/mapper) to appear.

> 
>> I see when that manual action takes place then systemd changes status of
>> a home.mount (which is in fstab) to "active" - and it's here where I
>> hope systemd would auto-start a service.
>> Is such a "simple" thing possible?
>> many thanks, L
>> ___
>> systemd-devel mailing list
>> systemd-devel@lists.freedesktop.org 
>> https://lists.freedesktop.org/mailman/listinfo/systemd-devel 
> 
> ___
> systemd-devel mailing list
> systemd-devel@lists.freedesktop.org 
> https://lists.freedesktop.org/mailman/listinfo/systemd-devel 



___
systemd-devel mailing list
systemd-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/systemd-devel