Skip to content

fc: add --rootfs-size to grow a microVM's rootfs at create time - #1150

Merged
cdalar merged 1 commit into
mainfrom
ai/rootfs-disk-size
Sep 28, 2026
Merged

cdalar merged 1 commit into
mainfrom
ai/rootfs-disk-size

Conversation

@cdalar

@cdalar cdalar commented Sep 28, 2026

Copy link
Copy Markdown
Owner

Summary

Adds onctl create --rootfs-size <MiB> (fc.rootfsSizeMib) for Firecracker: after a microVM's rootfs is copied from the base image, it's grown to that size, file and ext4 filesystem both. Default 0 keeps today's behavior.

Motivation: boxctl.io boxes all get the base image's 4 GiB disk regardless of size, so e.g. a Rancher install on a large (4 vCPU / 16 GiB) box dies on kubelet DiskPressure. With this, boxctl-vms can give each size its own disk from one small base image (companion: cdalar/boxctl-vms#108, which keeps pause/export diffs from shipping the grown tail's zeros).

Technical details

  • DebugfsRootfsPreparer.GrowRootfs: sparse truncate β†’ e2fsck -f -y (exit 1/2 = corrected, still usable; β‰₯4 fails) β†’ offline resize2fs. Costs no host disk until the guest writes; reflinked base blocks stay shared. Refuses to shrink below the base image; same size is a no-op.
  • New optional cloud.RootfsResizer interface, mirroring BaseImageIdentifier β€” but not best-effort: Deploy fails and cleans up the VM dir when a size is set and the preparer can't honor it, rather than booting a smaller disk than asked for.
  • Firecracker only. Cloud Hypervisor is untouched (boxctl.io only uses it for fixed-size Windows boxes).

Testing

  • New unit tests: grow call order and resulting size, no-op, shrink refusal (file untouched), e2fsck exit-code handling, resize2fs failure, and Deploy wiring (grows with the right path/size, default doesn't, failure cleans up, missing resizer fails).
  • TestDebugfsRootfsPreparer_GrowRootfs_RealExt4 runs real e2fsprogs on a real ext4 image and checks the filesystem's block count and a clean fsck. Skipped locally (macOS, no e2fsprogs) β€” should run on the Linux CI runner.
  • go test ./... passes with a clean HOME; go vet, gofmt, make clean. (With a real ~/.onctl present, TestReadConfig_NoConfigDirectory and TestCreateFlagsBindToViper fail on main too β€” they read the home config.)

πŸ€– Generated with Claude Code

https://claude.ai/code/session_01Ngxnc2n5dZEkDj6cR8KhNN

One small base image can now back microVMs with bigger disks: after the
rootfs is copied from the base image, it's sparse-extended to
fc.rootfsSizeMib and its ext4 filesystem grown offline (e2fsck -f, then
resize2fs). The extension costs no host disk until the guest writes
there, and the reflinked base blocks stay shared.

A separate, optional RootfsResizer interface like BaseImageIdentifier,
but Deploy fails when a size is set and the preparer can't honor it,
rather than booting a VM with a smaller disk than asked for. Shrinking
below the base image is refused. 0 (default) keeps today's behavior.

For boxctl.io's per-size box disks: every box currently gets the base
image's 4 GiB regardless of size, which isn't enough for e.g. Rancher.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ngxnc2n5dZEkDj6cR8KhNN
@codecov

codecov Bot commented Sep 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.
βœ… Project coverage is 36.85%. Comparing base (ea19670) to head (723be1a).

Files with missing lines Patch % Lines
internal/providerfc/common.go 93.33% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1150      +/-   ##
==========================================
+ Coverage   36.58%   36.85%   +0.27%     
==========================================
  Files          51       51              
  Lines        5615     5643      +28     
==========================================
+ Hits         2054     2080      +26     
- Misses       3561     3563       +2     

β˜” View full report in Codecov by Harness.
πŸ“’ Have feedback on the report? Share it here.

πŸš€ New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cdalar
cdalar merged commit 32f963a into main Sep 28, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ 捒网址