!PSmBFWNKoXmlQBzUQf:helsinki-systems.de

Stage 1 systemd

83 Members
systemd in NixOs's stage 1, replacing the current bash tooling https://github.com/NixOS/nixpkgs/projects/5127 Servers

Load older messages


SenderMessageTime
27 Nov 2022
@arianvp:matrix.orgArianWhich is probably too late22:37:34
@me:linj.tech@me:linj.tech
In reply to @janne.hess:helsinki-systems.de
you probably want cryptsetup.target in that before
Mounting /sysroot/nix... is before Reached target Local Encrypted Volumes., so before = [ "cryptsetup.target" ] is not enough I think
22:39:03
@arianvp:matrix.orgArian`unitConfig.DefaultDependencies=false`22:39:09
@elvishjerricco:matrix.org@elvishjerricco:matrix.org linj: as I understand it, preDeviceCommands in the old initrd basically means pre-udev. That is extremely early. 22:56:59
@me:linj.tech@me:linj.tech

Arian: your trick works!

pre-device-command = {
            description = "pre device command";
            wantedBy = [ "cryptsetup.target" ];
            wants = [ "cryptsetup-pre.target" ];
            before = [ "cryptsetup-pre.target" ];
            unitConfig.DefaultDependencies = false;
            # serviceConfig = {
            #   Type = "oneshot";
            #   RemainAfterExit = true;
            # };
            script = ''
              echo pre-device-command-start
              echo pre-device-command-end
            '';
          };
23:01:17
@arianvp:matrix.orgArianGreat 23:01:46
@elvishjerricco:matrix.org@elvishjerricco:matrix.org linj: I'm very curious what you're trying to achieve 23:01:51
@me:linj.tech@me:linj.techemm, what I want is somewhat weird: generate a keyfile on the fly for luks without storing that keyfile in initrd23:03:52
@me:linj.tech@me:linj.techon a vps23:04:23
@me:linj.tech@me:linj.tech another question: the before = [ "" ] does not seem to work: 59:50 localhost systemd[1]: Reached target Local Encrypted Volumes (Pre). is before 59:50 localhost systemd[1]: pre-device-command.service: Deactivated successfully. in journal 23:06:13
@me:linj.tech@me:linj.tech * another question: the before = [ "cryptsetup-pre.target" ] does not seem to work: 59:50 localhost systemd[1]: Reached target Local Encrypted Volumes (Pre). is before 59:50 localhost systemd[1]: pre-device-command.service: Deactivated successfully. in journal 23:06:25
@me:linj.tech@me:linj.tech
In reply to @me:linj.tech
another question: the before = [ "cryptsetup-pre.target" ] does not seem to work: 59:50 localhost systemd[1]: Reached target Local Encrypted Volumes (Pre). is before 59:50 localhost systemd[1]: pre-device-command.service: Deactivated successfully. in journal
oneshot does not change this
23:06:55
@arianvp:matrix.orgArianthere's an easier way to do that I think23:10:25
@arianvp:matrix.orgArian pretty sure you can do this with systemd-repart 23:16:51
@arianvp:matrix.orgArian (Using /dev/urandom as the keyfile) 23:17:12
@me:linj.tech@me:linj.techmy keyfile has a pre-defined key in it23:18:19
@me:linj.tech@me:linj.technot random23:18:29
@me:linj.tech@me:linj.tech
In reply to @me:linj.tech
oneshot does not change this
well, oneshot does make sure my service is before cryptsetup-pre.target. I confirm it with sleep 10
23:20:40
@me:linj.tech@me:linj.techthanks23:20:53
@me:linj.tech@me:linj.tech

It's weird that my pre-device-command.service and cryptsetup-pre.target stops after finishing running nixos activation script.

from man systemd.special:

this target (cryptsetup-pre.target) is particularly useful to ensure that a service is shut down only after all encrypted block devices are fully stopped.

23:27:01
@me:linj.tech@me:linj.techguess our initrd is not the same as what systemd's manual says23:28:06
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgHow is that not in line with the manual?23:28:25
@me:linj.tech@me:linj.tech I think what the manual says is that cryptsetup-pre.target should be stopped when the system is shutdown 23:29:44
@me:linj.tech@me:linj.techbut now, it is stopped after stage 223:29:54
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgThat's not quite accurate23:30:22
@elvishjerricco:matrix.org@elvishjerricco:matrix.org Stage 1 has two big systemd transactions. First is initrd.target, and after that there's a service called initrd-cleanup.service that does systemctl isolate initrd-switch-root.target, which is the second transaction. This causes everything else to be stopped 23:31:49
@elvishjerricco:matrix.org@elvishjerricco:matrix.orgSo that second transaction is in some ways very similar to system shutdown23:32:08
@elvishjerricco:matrix.org@elvishjerricco:matrix.org Any services in initrd that aren't supposed to be stopped by this (e.g. plymouth) need to either be wanted by initrd-switch-root.target, or have IgnoreOnIsolate=true 23:33:37
@arianvp:matrix.orgArian
In reply to @me:linj.tech
my keyfile has a pre-defined key in it
Then don't use /dev/urandom
23:34:18
@arianvp:matrix.orgArianBut the keyfile :)23:35:03

Show newer messages


Back to Room ListRoom Version: 6