Repository navigation
Description
Description
When a start asks for a smaller disk than the instance has, colima refuses the shrink but still saves the requested size in the profile's colima.yaml. colima list and colima status then report that saved size instead of the size the data disk actually has, and the stale value persists across restarts.
Two code paths are involved:
environment/vm/lima/disk.go, in the resize step: whenconf.Disk - instance.Diskis negative it logsdisk size cannot be reduced, ignoring...and returns, but the config with the smaller size is still saved.environment/vm/lima/limautil/instance.go, inInstances(): theDiskvalue fromlimactl listis overwritten withconf.Diskfrom the saved config (// report correct disk usage). After a refused shrink that value is not the disk's size.
Because instance.Disk is the saved config value and not the real size, a later start with a size between the stale value and the real size is treated as a grow. Colima calls limactl disk resize, lima refuses with Disk shrinking is currently unavailable, colima logs a warning, and the requested size is saved anyway.
Version
colima version v0.10.3
git commit: 00f6c297e92a82c04a4ab507db0a61435650d7e8
limactl version 2.2.0
qemu-img version 11.1.0
Operating System
- macOS Intel <= 13 (Ventura)
- macOS Intel >= 14 (Sonoma)
- Apple Silicon <= 13 (Ventura)
- Apple Silicon >= 14 (Sonoma)
- Linux
macOS 26.7.1, Apple Silicon, vmType qemu (default for this profile), mountType sshfs.
Output of colima status
colima [profile=captest-stale] is running using QEMU
arch: aarch64
runtime: containerd
mountType: sshfs
containerd socket: unix:///Users/<user>/.colima/captest-stale/containerd.sock
buildkitd socket: unix:///Users/<user>/.colima/captest-stale/buildkitd.sock
Reproduction Steps
Each step records colima list --json (disk field), limactl disk ls --json colima-captest-stale (size field, with LIMA_HOME=~/.colima/_lima), the disk: line of ~/.colima/captest-stale/colima.yaml, and df -h of the data disk mount inside the VM.
-
colima start -p captest-stale --cpu 1 --memory 2 --disk 20 --runtime containerdcolima list disk : 20 GiB limactl disk ls : 20 GiB colima.yaml : disk: 20 inside VM : 20G -
colima stop -p captest-stale && colima start -p captest-stale --disk 10level=warning msg="disk size cannot be reduced, ignoring..." context=vm colima list disk : 10 GiB limactl disk ls : 20 GiB colima.yaml : disk: 10 inside VM : 20G -
colima stop -p captest-stale && colima start -p captest-stale --disk 15level=warning msg="unable to resize disk: error resizing disk: exit status 1, output: ... specified size `15GiB` is less than the current disk size `20GiB`. Disk shrinking is currently unavailable" context=vm colima list disk : 15 GiB limactl disk ls : 20 GiB colima.yaml : disk: 15 inside VM : 20G -
colima stop -p captest-stale && colima start -p captest-stale --disk 25level=info msg="resizing disk to 25GiB..." context=vm colima list disk : 25 GiB limactl disk ls : 25 GiB colima.yaml : disk: 25 inside VM : 25G
Step 4 shows the values agree again once the requested size is above the real one.
Expected behaviour
After steps 2 and 3, colima list and colima status report 20 GiB, the size the data disk has, and the saved colima.yaml keeps disk: 20. A refused shrink should not change the recorded size.
Either of these would do it:
- Keep the previous
diskvalue in the saved config when the shrink is refused orlimactl disk resizefails, so the saved config keeps describing the instance. - Stop overriding the
limactl listdisk value inInstances(), or override it with the data disk's size fromlimactl disk ls, so the listing reports the real size regardless of the config.
Additional context
Tooling that drives colima from its own configuration hits this when a user lowers the disk setting and raises it again later: colima list under-reports until a start with a size at or above the stale value, and that start logs a resize although nothing changes. Not an urgent problem, since the real disk is never shrunk, but the saved config and the listing stop being a reliable description of the instance.
Activity
vm: keep the disk size of the instance when a shrink is refused