Skip to content

Commit

Permalink
fix: calculate UKI ISO size dynamically
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
smira committed Sep 15, 2023
1 parent 9698e45 commit 87c1b3d
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions pkg/imager/iso/uefi.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ type UEFIOptions struct {
const (
// mib is the size of a megabyte.
mib = 1024 * 1024
// UKIISOSizeAMD64 is the size of the AMD64 UKI ISO.
UKIISOSizeAMD64 = 80 * mib
// UKIISOSizeARM64 is the size of the ARM64 UKI ISO.
UKIISOSizeARM64 = 120 * mib
)

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

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

isoSize := int64(UKIISOSizeAMD64)
// initial size
isoSize := int64(10 * mib)

if options.Arch == "arm64" {
isoSize = UKIISOSizeARM64
for _, path := range []string{
options.SDBootPath,
options.UKIPath,
} {
st, err := os.Stat(path)
if err != nil {
return err
}

isoSize += (st.Size() + mib - 1) / mib * mib
}

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

0 comments on commit 87c1b3d

Please sign in to comment.