Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

systemd-boot: New /boot data format #337089

Open
ElvishJerricco opened this issue Aug 24, 2024 · 4 comments
Open

systemd-boot: New /boot data format #337089

ElvishJerricco opened this issue Aug 24, 2024 · 4 comments
Labels

Comments

@ElvishJerricco
Copy link
Contributor

The systemd-boot-builder.py script stores information about the profile, generation, and specialisation in the file name of loader entry .conf files. This has led to some issues where these names are improperly generated or parsed, e.g. the recent revert of boot counting: #334526.

I suggest a new format for these entry files. There should be a JSON file of a format something like this:

{
  "$profile": {
    "$generation": {
      "entry.conf": "$path_to_entry.conf",
      "files": [
        "$path_to_kernel"
        "$path_to_initrd"
        ...
      ]
    }
  }
}

This will make it easier to identify the locations of entry files as well as kernels, initrds, etc. to garbage collect.

When boot counting is reintroduced, the entry file name will refer to the name if it did not have any boot count included.

The entry name becomes arbitrary, giving us slightly better control over sorting.

This JSON file could have an ever-increasing number in its name, so that updates can be atomic without breaking the ability to GC the old one. When updating, make the new JSON file with the higher number, add the new files to the ESP, GC the old files from the ESP, and finally remove the old JSON file with the lower number. This way all the files that could need GC'ing will always have their corresponding JSON file present.

This is just a rough idea. And migration is going to be the tricky part. @alois31 recommended taking inspiration from when lanzaboote had to do something similar:

/cc @JulienMalka @Mic92 @r-vdp @NixOS/systemd

@ElvishJerricco ElvishJerricco added the 0.kind: bug Something is broken label Aug 24, 2024
@Atemu
Copy link
Member

Atemu commented Aug 25, 2024

Don't we already have the bootspec which fulfils a similar function?

@arianvp
Copy link
Member

arianvp commented Aug 26, 2024

It sounds to me we should (finally) rewrite systemd-boot-builder to properly use bootspec instead. I think there is some prior work for this in the lanzaboote repo if memory serves me well

@JulienMalka
Copy link
Member

systemd-boot-builder does use bootspec. I think the difference here is that essentially the bootspec is stateless whereas if I understand correctly this additionnal data would be stateful,

@ElvishJerricco
Copy link
Contributor Author

@Atemu, @arianvp Yes, the idea here is not to encode the same information as bootspec. It's instead to manage the stateful aspects of where and how we store boot entries in the ESP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: To Do
Development

No branches or pull requests

5 participants