Skip to content

Commit 87c1b3d

Browse files
committed
fix: calculate UKI ISO size dynamically
Fixes #7712 Instead of hardcoding a size, calculate the UKI and sd-boot size. UKI has dynamic size, as it depends on number of system extensions installed. Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
1 parent 9698e45 commit 87c1b3d

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

pkg/imager/iso/uefi.go

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ type UEFIOptions struct {
3636
const (
3737
// mib is the size of a megabyte.
3838
mib = 1024 * 1024
39-
// UKIISOSizeAMD64 is the size of the AMD64 UKI ISO.
40-
UKIISOSizeAMD64 = 80 * mib
41-
// UKIISOSizeARM64 is the size of the ARM64 UKI ISO.
42-
UKIISOSizeARM64 = 120 * mib
4339
)
4440

4541
// CreateUEFI creates an iso using a UKI, systemd-boot.
@@ -54,10 +50,19 @@ func CreateUEFI(printf func(string, ...any), options UEFIOptions) error {
5450

5551
efiBootImg := filepath.Join(options.ScratchDir, "efiboot.img")
5652

57-
isoSize := int64(UKIISOSizeAMD64)
53+
// initial size
54+
isoSize := int64(10 * mib)
5855

59-
if options.Arch == "arm64" {
60-
isoSize = UKIISOSizeARM64
56+
for _, path := range []string{
57+
options.SDBootPath,
58+
options.UKIPath,
59+
} {
60+
st, err := os.Stat(path)
61+
if err != nil {
62+
return err
63+
}
64+
65+
isoSize += (st.Size() + mib - 1) / mib * mib
6166
}
6267

6368
if err := utils.CreateRawDisk(printf, efiBootImg, isoSize); err != nil {

0 commit comments

Comments
 (0)