Skip to content

Fix: resize GuestOS disk #3437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

songponssw
Copy link
Contributor

Try to fix: #1448

How Lima edit disk

  • The limactl edit updates the disk value to the store. It does not resize disk image. Users have to manually resize by qemu-img
  • Does not support --shrink (fails to start instance)

What I did

  • create a limactl disk add command to add an existing qcow2 disk to Lima.
  • To update GuestOS disk, before start instance, It adds a diffdisk of the instance to Lima, resize, and delete.

@songponssw songponssw marked this pull request as ready for review April 17, 2025 05:34
@songponssw songponssw marked this pull request as draft April 17, 2025 05:34
@songponssw songponssw force-pushed the feat-edit-disk branch 2 times, most recently from b3f95e5 to a0800cf Compare April 17, 2025 09:18
@songponssw songponssw closed this Apr 25, 2025
@songponssw songponssw reopened this Apr 25, 2025
@songponssw
Copy link
Contributor Author

This implementation works fine for increasing the disk size.
However, it returns an error when shrinking, as disk shrinking is not supported.

@AkihiroSuda
Copy link
Member

Needs rebase

@songponssw
Copy link
Contributor Author

Summary of Latest Review:

  1. DiskDir is dedicated to additional disks.
    • I've updated the implementation by creating a new ResizeDiffDisk function, which directly resizes the diffdisk.
  2. Calling inst.inspect() twice:
    • The editAction function returns instance.Start which doesn’t update the validated configuration in the store or the instance yet.
    • The second call to inst.inspect() is to apply the new configuration.
    • The first call to inst.inspect() checks whether the instance exists and is running.

@jandubois
Copy link
Member

Note that #3513 moved the qemu-img functions to pkg/qemu/imgutil.

Signed-off-by: Songpon Srisawai <songpon.ssw@gmail.com>
@songponssw songponssw marked this pull request as ready for review May 10, 2025 14:31

// store.Inspect() syncs values between inst.YAML and the store.
// This call applies the validated template to the store.
inst, err = store.Inspect(inst.Name)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x104ceed71]

goroutine 1 [running]:
main.editAction(0xc0005acf08, {0xc0000ce960?, 0x4?, 0x104d7fff4?})
	/Users/runner/work/lima/lima/cmd/limactl/edit.go:139 +0x731
github.com/spf13/cobra.(*Command).execute(0xc0005acf08, {0xc0000ce910, 0x5, 0x5})
	/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1015 +0xa94
github.com/spf13/cobra.(*Command).ExecuteC(0xc00059c008)
	/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1148 +0x40c
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/runner/go/pkg/mod/github.com/spf13/cobra@v1.9.1/command.go:1071
main.main()
	/Users/runner/work/lima/lima/cmd/limactl/main.go:41 +0x18

https://github.com/lima-vm/lima/actions/runs/14946273265/job/41989994774?pr=3437

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.

Changing the disk size in lima.yaml should resize the disk
3 participants