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:
- 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:
- 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.
The only thing the spec says about boot entries is:
If you read the spec as is, you'd assume that Type#2 entries have no
sort-keyand thus are only sorted by their filename as per option 4:But this is not the case. As systemd infers the
sort-keyfrom theIDorIMAGE_IDfield and theversionfrom theIMAGE_VERSION | VERSION | VERSION_ID | BUILD_IDfield.https://github.com/systemd/systemd/blob/608fc3fa2c4902d84fd925b328b730d3b2dbff50/src/fundamental/bootspec-fundamental.c#L47C9-L47C22
So it's actually sorted as specified by:
before sorting by file-name.