Skip to content

How sorting works for for Type#2 entries works is under-specified #169

@arianvp

Description

@arianvp

The only thing the spec says about boot entries is:

Of these sections, the .osrel section is used to generate boot entries. The PRETTY_NAME= and VERSION_ID= fields in the embedded os-release file are used the same as title and version in the Type #1 entries. The .cmdline section is used instead of the options field. linux and initrd fields are not necessary, and there is no counterpart for the machine-id field.

If you read the spec as is, you'd assume that Type#2 entries have no sort-key and thus are only sorted by their filename as per option 4:

  1. At the end, if necessary, when sort-key is not set or those fields are not set or are all equal, the boot loader should sort using the file name of the entry (decreasing version sort), with the suffix removed.

But this is not the case. As systemd infers the sort-key from the ID or IMAGE_ID field and the version from the IMAGE_VERSION | VERSION | VERSION_ID | BUILD_ID field.

https://github.com/systemd/systemd/blob/608fc3fa2c4902d84fd925b328b730d3b2dbff50/src/fundamental/bootspec-fundamental.c#L47C9-L47C22

So it's actually sorted as specified by:

  1. If sort-key is set on both entries, use in order of priority, the sort-key (A-Z, increasing alphanumerical order), machine-id (A-Z, increasing alphanumerical order), and version keys (decreasing version order).

before sorting by file-name.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions