Skip to content

Support LUKS reencryption in repart #29824

Open

Description

@Cornelicorn

Component

systemd-repart

Is your feature request related to a problem? Please describe

With mkosi it is possible to generate encrypted disk images, which can easily deployed to machines, especially virtual machines. The downside with deploying the same image multiple times is that they will all use the same drive encryption key unless the image is generated again between deployments. It would be nice if systemd-repart could do a reencryption of a drive on the first boot.

Describe the solution you'd like

A new option for systemd-repart which starts a reencryption of a drive, allowing to deploy the same encrypted image multiple times.

I'm not sure that systemd-repart has any way to identify the first boot where this should happen, so maybe this can be stored as a GPT attribute and whenever that is set, it will begin/continue a reencryption. After the reencryption is done, the flag is set to 0.

The benefit of putting this into repart would be that this could (with a kernel command line option / config option in repart.d to toggle the behaviour) be run before the partition and luks mapper is grown, so the reencrypt doesn't run for possibly hundreds of GB, but just the size of the original image (probably a few GB or les only).

Describe alternatives you've considered

A naive solution to mitigate this would be to put a service in the image that starts on firstboot and starts cryptsetup reencrypt as well as cryptsetup reencrypt --resume-only on the next boots. This is a process that can be interrupted.

The systemd version you checked that didn't have the feature you are asking for

No response

Activity

  1. added
    RFE 🎁
    on Nov 1, 2023
  2. Cornelicorn commented on Nov 1, 2023

    @Cornelicorn
    ContributorAuthor

    Maybe this should also rather go into systemd-gpt-auto-generator than repart?
    Growing the LUKS mapper would be done there as far as I understand.

  3. bluca commented on Nov 1, 2023

    @bluca
    Member

    Why not just encrypt on first boot, instead of shipping it already encrypted?

  4. Cornelicorn commented on Nov 1, 2023

    @Cornelicorn
    ContributorAuthor

    Mainly to have the ability to ship secrets inside the image so the machines can be deployed without manual intervention and can call back into a central service to get config management options. An encrypted image could also be sent to manufacturers who support pre-imaging a computer with an image the company provides, so devices can be sent directly to people instead of going through an IT department for imaging.

  5. poettering commented on Nov 1, 2023

    @poettering
    Member

    See #29731

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    RFE 🎁repart

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions