Skip to content

An open-source, faster Devin alternative

TypeScript

20gb rootfs

Brian Reardona6bc6fd15ef6
diff --git a/internal/qemu/manager.go b/internal/qemu/manager.go
index 5acd132b..82654625 100644
--- a/internal/qemu/manager.go
+++ b/internal/qemu/manager.go
@@ -476,6 +476,26 @@ func (m *Manager) PrepareGoldenSnapshot() error {
}
log.Printf("qemu: golden: virtio_mem module loaded")
+ // Grow rootfs filesystem to fill the expanded virtual disk.
+ // The qcow2 overlay was resized to 20 GB but the ext4 filesystem still
+ // matches the smaller base image. resize2fs expands it in-place.
+ growCtx, growCancel := context.WithTimeout(context.Background(), 30*time.Second)
+ growResp, growErr := agentClient.Exec(growCtx, &pb.ExecRequest{
+ Command: "/bin/sh",
+ Args: []string{"-c", "resize2fs /dev/vda"},
+ RunAsRoot: true,
+ })
+ growCancel()
+ if growErr != nil || (growResp != nil && growResp.ExitCode != 0) {
+ stderr := ""
+ if growResp != nil {
+ stderr = growResp.Stderr
+ }
+ log.Printf("qemu: golden: resize2fs /dev/vda failed (non-fatal): %v %s", growErr, stderr)
+ } else {
+ log.Printf("qemu: golden: rootfs expanded to 20GB")
+ }
+
// Unmount /home/sandbox and sync before snapshot — the golden migration state
// includes virtio-blk device state (ring buffers, pending I/O). If the data disk
// is mounted when we snapshot, those stale I/O ops will corrupt any fresh
@@ -1302,6 +1322,16 @@ func (m *Manager) Create(ctx context.Context, cfg types.SandboxConfig) (*types.S
}
vm.agent = agentClient
+ // Grow rootfs filesystem if the disk is larger than the current ext4 fs.
+ // Golden-forked sandboxes already have the grown fs; this covers cold boot.
+ growCtx, growCancel := context.WithTimeout(context.Background(), 10*time.Second)
+ agentClient.Exec(growCtx, &pb.ExecRequest{
+ Command: "/bin/sh",
+ Args: []string{"-c", "resize2fs /dev/vda 2>/dev/null"},
+ RunAsRoot: true,
+ })
+ growCancel()
+
envsToInject := m.sealSandboxEnvs(context.Background(), id, netCfg, agentClient, cfg)
if len(envsToInject) > 0 {
envCtx, envCancel := context.WithTimeout(context.Background(), 5*time.Second)
diff --git a/internal/qemu/rootfs.go b/internal/qemu/rootfs.go
index e9e131a7..ef4486b0 100644
--- a/internal/qemu/rootfs.go
+++ b/internal/qemu/rootfs.go
@@ -32,6 +32,13 @@ func PrepareRootfs(baseImage, destPath string) error {
return fmt.Errorf("create qcow2 overlay: %w (%s)", err, strings.TrimSpace(string(out)))
}
+ // Expand the virtual size to 20 GB. The qcow2 is thin-provisioned so host
+ // disk usage stays proportional to actual writes, not virtual size.
+ resizeCmd := exec.Command("qemu-img", "resize", destPath, "20G")
+ if out, err := resizeCmd.CombinedOutput(); err != nil {
+ return fmt.Errorf("resize rootfs overlay: %w (%s)", err, strings.TrimSpace(string(out)))
+ }
+
return nil
}