<div dir="auto">I forgot to say that the devices on crypttab are also configured with `noauto`, that's why I was adding the dependences manually.<div dir="auto"><br></div><div dir="auto">The strange behavior for me is that, if I do not put the `<span style="font-family:sans-serif">x-systemd.automount` everything works fine: the devices are not decrypted until I try to mount the final filesystem. But when I add the automount feature, the devices get automatically decrypted at boot, because the dependencies are moved from the .mount to the .automount.</span></div><div dir="auto"><span style="font-family:sans-serif"><br></span></div><div dir="auto">This can be solved manually with custom units, but I would like to know if there is an explanation for this behavior.</div><div dir="auto"><br></div><div dir="auto">Thanks.</div><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">El vie., 30 ago. 2019 12:05, Michael Chapman <<a href="mailto:mike@very.puzzling.org">mike@very.puzzling.org</a>> escribió:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, 30 Aug 2019, Daniel Otero Oubiña wrote:<br>
> Hi all!<br>
> <br>
> I have found a somehow strange systemd "feature" that I'm not sure if it's<br>
> a bug. Let me know if you prefer having this reported on GitHub instead.<br>
> <br>
> First, let me explain my setup: I have a data filesystem that is split in<br>
> two encrypted partitions (with LUKS) formated as a single btrfs raid1<br>
> filesystem.<br>
> I manage to make everything work just modifying fstab and crypttab.<br>
> <br>
> The problem arises when I try to make the data partition mounted on demand<br>
> (`x-systemd.automount`). That's because it makes my "decrypted partitions"<br>
> dependences (declared with `systemd.requires=systemd-cryptsetup@xxx.service`)<br>
> move from the .mount autogenerated unit to the .automount one. This causes<br>
> the partitions to be decrypted even if the data filesystem is never used,<br>
> because the .automount unit is activated on boot. Is there a reasoning for<br>
> this behavior or I'm missing something?<br>
> <br>
> Here is a link with the autogenerated units with and without the automount<br>
> option:<br>
> <a href="https://pastebin.com/RkdHFt59" rel="noreferrer noreferrer" target="_blank">https://pastebin.com/RkdHFt59</a><br>
<br>
First, I don't think you should specify <br>
x-systemd.requires=systemd-cryptsetup@xxx.service explicitly.<br>
<br>
systemd's cryptsetup-generator ensures that cryptsetup.target has <br>
Wants=systemd-cryptsetup@xxx.service, and systemd-cryptsetup@xxx.service <br>
has BindsTo=dev-yyy.device according to the contents of your crypttab <br>
file.<br>
<br>
The end result is cryptsetup should be performed when the device is <br>
detected, not necessarily when any filesystem on it is mounted. That is <br>
the behaviour you're seeing already, but without any need for explicit <br>
dependencies.<br>
<br>
As for whether this behaviour is intended, I would say it is. An encrypted <br>
block device might be used for something other than a mountable <br>
filesystem. You might have LVM on it, for instance.</blockquote></div></div>