<div dir="auto"><div>Responses inline<br><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Oct 19, 2024, 21:52 Thayne Harbaugh <<a href="mailto:thayne@mastodonlabs.com">thayne@mastodonlabs.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Response in line:<br>
<br>
On Sat, 2024-10-19 at 20:36 -0400, Adrian Vovk wrote:<br>
> Hello,<br>
> I might have spotted something <br>
<br>
Thank you for reviewing my long email.<br>
<br>
> You tell repart to encrypt with a keyfile, but it seems like you<br>
> don't pass in which keyfile to use.<br>
<br>
Maybe I'm confused about how Encrypt= and EncryptedVolume= interact.<br>
<br>
>From repart.d(5) v256.7:<br>
<br>
EncryptedVolume=<br>
Specify how the encrypted partition should be set up. Takes at<br>
least one and at most three fields separated with a colon<br>
(":"). The first field specifies the encrypted volume name<br>
under /dev/mapper/. If not specified, "luks-UUID" will be used<br>
where "UUID" is the LUKS UUID. The second field specifies the<br>
keyfile to use following the same format as specified in<br>
crypttab. The third field specifies a comma-delimited list of<br>
crypttab options. These fields correspond to the first, third<br>
and fourth column of the crypttab(5) format.<br>
<br>
Note that this setting is only taken into account when<br>
--generate-crypttab= is specified on the systemd-repart<br>
command line.<br>
<br>
Added in version 256.<br>
<br>
My (possibly incorrect) understanding is that EncryptedVolume=<br>
specifies the key-file in the second position - which in my demo code<br>
is the following:<br>
<br>
Encrypt=key-file<br>
EncryptedVolume=dc-xdata:/run/fscrypt.sock:luks,discard<br>
<br>
Which would then be /run/fscrypt.sock. Am I confused about Encrypt=<br>
and EncryptedVolume= ?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Yeah I think you are. I'm pretty sure EncryptedVolume= is about defining what goes into /etc/crypttab, and thus how the volume is set up at runtime or at boot. Not how the volume is set up when it's created. Basically each EncryptedVolume= entry is an entry in /etc/crypttab and no more.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> By default, repart will encrypt<br>
> with a null key in that case. IIRC, you have to pass in the keyfile<br>
> (or maybe socket) to use in your drop-in.<br>
<br>
I feel like I should know what my "drop-in" ... but I have no idea.<br>
Is thet the repart.d/30-xdata.conf? Is it the override I made to<br>
systemd-repart.service as<br>
systemd-repart.service.d/systemd-repart-gen_tabs.conf ?<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">I mean the override you made to systemd-repart.service</div><div dir="auto"><br></div><div dir="auto">Best,</div><div dir="auto">Adrian </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> Apologies if I'm wrong. I'm on my phone and haven't pulled up the<br>
> docs to verify.<br>
<br>
Maybe you can send something with more details when you have access to<br>
a system.<br>
<br>
Thank you for the response.</blockquote></div></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
> Best,<br>
> Adrian <br>
> <br>
> On Sat, Oct 19, 2024, 20:21 Thayne Harbaugh <<a href="mailto:thayne@mastodonlabs.com" target="_blank" rel="noreferrer">thayne@mastodonlabs.com</a>><br>
> wrote:<br>
> > Greetings - apologies if this isn't the proper list - please<br>
> > redirect<br>
> > me.<br>
> > <br>
> > I'm writing a systemd-repart HOWTO with demo code for various use<br>
> > cases:<br>
> > <br>
> > <a href="https://github.com/plastikos/repart_howto" rel="noreferrer noreferrer" target="_blank">https://github.com/plastikos/repart_howto</a><br>
> > <br>
> > The HOWTO is a typical document while the demos are minimal cases<br>
> > built with mkosi and available for growing into larger solutions.<br>
> > <br>
> > Initially it has two use-case demos:<br>
> > <br>
> > 1. Creating a new partition (xdata) on first boot<br>
> > <br>
> > 2. Creating a new partition (xdata) with encryption on first boot<br>
> > <br>
> > Currently #1 works. It's simple. I still need to create more<br>
> > details<br>
> > around growing partitions and other ideas.<br>
> > <br>
> > The encryption case #2, however, does not work and I'm looking for<br>
> > some assistance. While there is significant documentation around<br>
> > the<br>
> > systemd ecosystem of tools I feel like I have possibly missed some<br>
> > detail or may not be understanding how to synthesize the<br>
> > information<br>
> > into a working model.<br>
> > <br>
> > The encryption demo is identical to case #1 of adding a partition<br>
> > with<br>
> > the following changes:<br>
> > <br>
> > 1. The /usr/lib/repart.d/30-xdata.conf file adds the following:<br>
> > <br>
> > Encrypt=key-file<br>
> > EncryptedVolume=dc-xdata:/run/fscrypt.sock:luks,discard<br>
> > <br>
> > 2. a /usr/lib/systemd/system/fscrypt.socket file is added along<br>
> > with<br>
> > a fscrypt@.service file (see the project source, please).<br>
> > <br>
> > 3. A /usr/bin/getkey file is added for fscrypt@.service to call.<br>
> > getkey provides a simplistic way of producing an encryption<br>
> > key<br>
> > for *demonstration* purposes *ONLY*.<br>
> > <br>
> > 4. A /var/lib/key.bin is added as a binary encryption key that<br>
> > getkey retrieves - for *demonstration* purposes *ONLY*.<br>
> > <br>
> > When built into a disk image by mkosi and started with qemu it<br>
> > fails<br>
> > to create the new xdata partition. I see quite a few journal<br>
> > messages<br>
> > from systemd-repart and related udev events. I have verified a few<br>
> > things:<br>
> > <br>
> > 1. /run/fscrypt.sock does get created<br>
> > <br>
> > 2. getkey does emit the encryption key to stdout<br>
> > <br>
> > 3. systemd-repart is started and initiates creating a partition<br>
> > with<br>
> > LUKS<br>
> > <br>
> > There are two notable details that cause me concern and might be<br>
> > where<br>
> > the problem lies:<br>
> > <br>
> > 1. There is no evidence that getkey is invoked even when I<br>
> > instrument it to generate side-effects.<br>
> > <br>
> > 2. There are messages in the journal that indicate that<br>
> > systemd-repart never exits and that it might be in deadlock<br>
> > waiting<br>
> > for child events.<br>
> > <br>
> > The messages around the possible deadlock of #2 above are the<br>
> > following:<br>
> > <br>
> > Oct 19 12:08:48.510843 localhost systemd-repart[276]: loop0:<br>
> > Acquired exclusive lock.<br>
> > Oct 19 12:08:48.512130 localhost systemd-repart[276]:<br>
> > Successfully acquired /dev/loop0, devno=7:0, nr=0, diskseq=11<br>
> > Oct 19 12:08:48.516941 localhost systemd-repart[276]: Encrypting<br>
> > future partition 2...<br>
> > Oct 19 12:08:48.517077 localhost systemd-repart[276]: Allocating<br>
> > context for crypt device /dev/loop0.<br>
> > <SNIP/><br>
> > Oct 19 12:08:49.114118 localhost (udev-worker)[299]: loop0:<br>
> > Processing device (SEQNUM=1996, ACTION=change)<br>
> > Oct 19 12:08:49.114972 localhost (udev-worker)[299]: loop0:<br>
> > Failed to flock(/dev/loop0): Resource temporarily unavailable<br>
> > Oct 19 12:08:49.114979 localhost (udev-worker)[299]: loop0: Block<br>
> > device is currently locked, requeueing the event.<br>
> > <SNIP/><br>
> > Oct 19 12:08:49.328308 localhost (udev-worker)[296]: loop0:<br>
> > Processing device (SEQNUM=1996, ACTION=change)<br>
> > Oct 19 12:08:49.328345 localhost (udev-worker)[296]: loop0:<br>
> > Failed to flock(/dev/loop0): Resource temporarily unavailable<br>
> > Oct 19 12:08:49.328352 localhost (udev-worker)[296]: loop0: Block<br>
> > device is currently locked, requeueing the event.<br>
> > <SNIP/><br>
> > <br>
> > Those last three messages about failing to lock repeat until QEMU<br>
> > is<br>
> > shut down.<br>
> > <br>
> > There are quite a few additional diagnostic details and logs that<br>
> > may<br>
> > be of interest but it might be easier to clone the repart_howto<br>
> > project from github and run it:<br>
> > <br>
> > >$ ./demo crypt<br>
> > <br>
> > Once it executes all of the mkosi configuration files and disk<br>
> > image<br>
> > are in the build-crypt sub-directory. All relevant files specific<br>
> > to<br>
> > partition creation and encryption are in build-crypt/mkosi.extra -<br>
> > there are not many since I'm trying to keep the demo as simple as<br>
> > possible. All relevant journal events and state information can be<br>
> > extracted from build-crypt/image.raw.<br>
> > <br>
> > Thanks for either directing me to a more appropriate help resource<br>
> > and/or providing direct assistance.<br>
> > <br>
> > <br>
> > P.S. If you want to run demo #1 of partition creation sans<br>
> > encryption<br>
> > then execute the following from the project source tree:<br>
> > <br>
> > >$ ./demo clear<br>
<br>
-- <br>
Big Solutions<br>
</blockquote></div></div></div>