imagepull/BuildExt4: omit positional fs-size; rely on file truncation
mkfs.ext4's positional fs-size is documented in 1 KiB units (not the filesystem's 4 KiB block size), so passing sizeBytes/4096 made filesystems 1/4 the intended size. A 4 GiB request became a 1 GiB ext4 in a 4 GiB file, packed to 0 free blocks — VM create then failed with 'Could not allocate block' when patchRootOverlay tried to write guest config. The file is truncated to the target size before mkfs runs; without the positional arg, mkfs uses the whole device. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
b2dcdf9757
commit
ed4117d926
1 changed files with 5 additions and 2 deletions
|
|
@ -5,7 +5,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"banger/internal/system"
|
||||
)
|
||||
|
|
@ -53,6 +52,11 @@ func BuildExt4(ctx context.Context, runner system.CommandRunner, srcDir, outFile
|
|||
return err
|
||||
}
|
||||
|
||||
// mkfs.ext4's positional `fs-size` is documented in 1 KiB units
|
||||
// (NOT the filesystem's 4 KiB block size), so dividing by 4096
|
||||
// produces a filesystem 1/4 the intended size. Omit the positional
|
||||
// entirely — the file was truncated to sizeBytes above, and mkfs
|
||||
// with no fs-size arg uses the whole device.
|
||||
out, runErr := runner.Run(ctx, "mkfs.ext4",
|
||||
"-F",
|
||||
"-q",
|
||||
|
|
@ -60,7 +64,6 @@ func BuildExt4(ctx context.Context, runner system.CommandRunner, srcDir, outFile
|
|||
"-L", "banger-rootfs",
|
||||
"-E", "root_owner=0:0",
|
||||
outFile,
|
||||
strconv.FormatInt(sizeBytes/4096, 10), // size in 4 KiB blocks
|
||||
)
|
||||
if runErr != nil {
|
||||
_ = os.Remove(outFile)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue