1 |
On Fri, Nov 16, 2018 at 12:15 PM Andrew Udvare <audvare@×××××.com> wrote: |
2 |
> |
3 |
> I am not sure if there is a way to move the systemd-cryptsetup@××××.service up the dependency tree once it's working, which would then remove the mnt-chuan.mount dependency. |
4 |
> |
5 |
|
6 |
Ok, I did a bit more reading. You're using the cryptsetup generator |
7 |
most likely. It sets up units to be oneshot+remainafterexit, which |
8 |
means they're "active" whenever the LUKS device is mounted (without |
9 |
any processes - but they show as active so that you can stop them and |
10 |
unmount the device). It sets the RequiresMountsFor parameter for the |
11 |
device the key file is contained on, which makes that mount service a |
12 |
Required dependency. That means that it can't be unmounted while the |
13 |
cryptsetup device is in use, and in theory attempting to unmount the |
14 |
key file should make systemd attempt to unmount the cryptsetup device |
15 |
(though busy filesystems could interfere with that). |
16 |
|
17 |
I'm not sure if there is a cleaner solution for this without adding |
18 |
some kind of new dependency type to systemd. You really do want that |
19 |
mountpoint to be considered "Required" when the service starts as that |
20 |
file is essential, but you don't need it to stick around after the |
21 |
unit starts. Of course, you don't want it to automatically stop right |
22 |
away either (that would create a race condition between unmounting the |
23 |
key and reading it). |
24 |
|
25 |
This is built-in systemd behavior. I wouldn't be surprised if the |
26 |
folks on the #systemd IRC channel would be interested in talking about |
27 |
this use case and ways to improve it. The fact that they anticipate |
28 |
the key being on a removable mount makes me think it is something they |
29 |
want to support, but it would clearly be more secure to not leave that |
30 |
file mounted all the time. |
31 |
|
32 |
I'd encourage you to ask about it on IRC. If that isn't something you |
33 |
want to do I might inquire about it myself, but I don't want to steal |
34 |
your thunder. |
35 |
|
36 |
-- |
37 |
Rich |