microsoft / microsoft/azure-linux-image-tools
[Bug]: COSI build with systemd-boot doesn't detect loader entries on EFI partition
- Dominant language
- Go
- Stars
- 37
- Forks
- 11
- Avg merge
- 1d 15h
- Merged PRs (30d)
- 15
Description
**Bug Description**
COSI build doesn't extract UAPI type 1 (non-UKI) loader entries (/loader/entries/) from EFI partition. MIC only checks the legacy boot partition for loader entries and will fail if none are present despite valid loader entries on EFI partition. systemd-boot supports the EFI directory for loader entries files. Same setup with VHDX as the output functions correctly
**Expected behavior**
COSI build succeeds
**Actual behavior**
```shell
FATA[0042] image customization failed:
failed to collect OS information:
failed to extract bootloader metadata:
systemd-boot detected, but no supported boot entries found
```
**Logs / Output**
See above
**Reproduction Steps**
Steps to reproduce the behavior:
1. Command line used (please paste the full command):
```shell
customize
--build-dir
--config-file /path/to/mic.yaml
--image-file base.vhdx
--log-level debug
--output-image-format cosi
--output-image-file vm.cosi
--rpm-source
```
2. Relevant portion of the configuration file (YAML/JSON). Please redact any
secrets:
```yaml
os:
hostname: my-vm
bootloader:
resetType: hard-reset
packages:
install:
- systemd-boot
...
```
3. Any additional steps:
Remove any preexisting grub packages and configs if present. Install systemd-boot on EFI partition and also install the loader entries file on EFI partition. All required boot artifacts (kernel, initrd) are present on EFI partition as described by entries file.
**Environment**
- How was Image Customizer invoked? container image
- Host OS and version Azure Linux 3.0:
- Host architecture x86_64:
- Base image used: vhdx
- Target image format: COSI
**Image Customizer version**
1.6.0
**Additional context**
When I set the output to `vhdx` instead of COSI, a hyperv VM boots just fine with this setup.
[systemd-boot docs](https://www.man7.org/linux//man-pages/man7/sd-boot.7.html)
```text
Boot entry description files following the UAPI.1 Boot Loader
Specification[1] are read from /loader/entries/ on the ESP and the
Extended Boot Loader partition.
```
Code in question is probably [this](https://github.com/microsoft/azure-linux-image-tools/blob/main/toolkit/tools/pkg/imagecustomizerlib/cosicommon.go#L460)
Contributor guide
Research direction
Start at toolkit/tools/pkg/imagecustomizerlib/cosicommon.go around the linked line and trace how COSI collects systemd-boot metadata and searches for loader entries. Reproduce the issue with the provided customize command and EFI-partition layout; done means the COSI build succeeds when UAPI type 1 entries exist on the EFI partition.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- build-system, operating-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100