Problem
GCP requires that disk.raw files are aligned to a GiB boundary (a multiple of 1,073,741,824 bytes). The gce image type currently produces a disk.raw that may not satisfy this requirement, depending on the requested image size and filesystem layout. This causes GCP import to fail.
Root cause
In pkg/distro/generic/bootc_imagetype.go, genPartitionTableFsCust() uses imageSize derived from ImageTypeYAML.DefaultSize (or basept.Size) directly, without rounding up to the nearest GiB:
// pkg/distro/generic/bootc_imagetype.go:918
imageSize := t.ImageTypeYAML.DefaultSize
if basept.Size != 0 {
imageSize = basept.Size
}
return disk.NewPartitionTable(basept, fsCustomizations, imageSize, ...)
The gce entry in data/distrodefs/bootc-generic/imagetypes.yaml (lines 148–152) has no alignment constraint:
"gce":
<<: *raw_image_type
filename: "image.tar.gz"
mime_type: "application/gzip"
exports: ["gce"]
Proposed fix
Option A (recommended) — align at partition table generation time
- Add a GiBAlignedDisk bool field to ImageTypeYAML in pkg/distro/defs/loader.go:
GiBAlignedDisk bool yaml:"gib_aligned_disk"
- Set it in data/distrodefs/bootc-generic/imagetypes.yaml:
"gce":
<<: *raw_image_type
filename: "image.tar.gz"
mime_type: "application/gzip"
exports: ["gce"]
gib_aligned_disk: true
- In genPartitionTableFsCust(), round imageSize up before calling NewPartitionTable:
if t.ImageTypeYAML.GiBAlignedDisk {
imageSize = (imageSize + datasizes.GiB - 1) &^ (datasizes.GiB - 1)
}
Option B — resize in the GCE pipeline
Add a truncate/pad stage in pkg/image/gce.go after the disk image is built and before the tar step. More invasive and happens after the fact rather than sizing correctly up front.
Why Option A
It ensures disk.raw is sized correctly from the start — no post-processing or repackaging needed. The datasizes.GiB constant (1 << 30) is already available in pkg/datasizes/constants.go.
Problem
GCP requires that disk.raw files are aligned to a GiB boundary (a multiple of 1,073,741,824 bytes). The gce image type currently produces a disk.raw that may not satisfy this requirement, depending on the requested image size and filesystem layout. This causes GCP import to fail.
Root cause
In pkg/distro/generic/bootc_imagetype.go, genPartitionTableFsCust() uses imageSize derived from ImageTypeYAML.DefaultSize (or basept.Size) directly, without rounding up to the nearest GiB:
The gce entry in data/distrodefs/bootc-generic/imagetypes.yaml (lines 148–152) has no alignment constraint:
Proposed fix
Option A (recommended) — align at partition table generation time
GiBAlignedDisk bool
yaml:"gib_aligned_disk""gce":
<<: *raw_image_type
filename: "image.tar.gz"
mime_type: "application/gzip"
exports: ["gce"]
gib_aligned_disk: true
if t.ImageTypeYAML.GiBAlignedDisk {
imageSize = (imageSize + datasizes.GiB - 1) &^ (datasizes.GiB - 1)
}
Option B — resize in the GCE pipeline
Add a truncate/pad stage in pkg/image/gce.go after the disk image is built and before the tar step. More invasive and happens after the fact rather than sizing correctly up front.
Why Option A
It ensures disk.raw is sized correctly from the start — no post-processing or repackaging needed. The datasizes.GiB constant (1 << 30) is already available in pkg/datasizes/constants.go.