-
Notifications
You must be signed in to change notification settings - Fork 661
Enable trimming of the diffdisk
#356
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
Comments
Will this patch+fstrim+qemu-img do the trick? That will be slightly better than building virt-sparsify on a Mac or running it in a secondary VM. |
I don't know (can you try and let us know?); I was hopping for Having to copy the image after running I'm not sure how well macOS support sparse files directly; I'm only aware of |
Another thing to test would be to try this patch on Linux and see if it just works (I fully expect it to). That way we'll know if the issue is with the patch, or with the host OS. |
As far as I remember, you had to copy the image offline (with |
Yeah, that's what @dee-kryvenko is referring to above. The problem is that when you want to reclaim space (because you have run out, or are close to it), you most likely don't have space for another (temporary) copy. |
What happens if I delete the file? It has grown to 60GB on my system. |
It will break the VM. Maybe Alpine would recover because it is just a separate volume and not a real diffdisk, but it would be better/cleaner to just delete and recreate the VM. |
Can someone please reveal full algorithm, step by step with commands, how to reclaim space, while I still have space 😅 |
Something like this: $ limactl stop
$ qemu-img convert -O qcow2 -B ~/.lima/default/basedisk ~/.lima/default/diffdisk ~/.lima/default/diffdisk.new
$ mv ~/.lima/default/diffdisk ~/.lima/default/diffdisk.old
$ mv ~/.lima/default/diffdisk.new ~/.lima/default/diffdisk
$ limactl start It's not always obvious what the real file size is though, with sparse files and such. So might need to check also with Assuming that your question was not how to clean up space inside the VM ? EDIT: Nope, that would require some more work before it actually works .... Important to still have the same base disk and format as the original image. |
Thank you for the answer, but I got |
I think the Ultimately it would need some more clever tool within lima, like https://libguestfs.org/virt-sparsify.1.html |
I made it a hard way :)
Thus I've managed to reduce |
In my test, just add Right now I have to get qemu args from debug logs, then manually exec qemu with the added |
@CzBiX, I can confirm that with Here's the QEMU arg:
|
@chrisx8 Sorry to abuse this issue to contact you, but do you happen to know a way to resize the |
@jandubois You can resize the virtual disks with
Some examples: # Grow diffdisk to 200GB
qemu-img resize ~/.lima/default/diffdisk 200G
# Increase the size by 10GB (note the + sign)
qemu-img resize ~/.lima/default/diffdisk +10G Also, I wouldn't mind helping out if you'd like! Feel free to open issue and tag me along. If you prefer email, let me know here and I'll reach out. |
Is there already a follow-up issue to automatically run |
@PKizzle you'd have to configure a service in the VM to do that for you. |
There is no good way to run something from the guest-agent when you stop the VM. I'm not sure if we would get a SIGTERM before it gets killed. It would be trivial to run |
I want to also highlight there is a specific
|
Hello, is there an easy way to find what the location of ~/.lima/default/diffdisk is? Mine does not seem to be here, when i run the resize i get "No such file or directory". I cannot prune my images or containers because the docker daemon doesn't start without rancher desktop... |
* Resolves lima-vm#356 * Add 'discard=on' argument to '-drive' flag for basedisk and diffdisk, so that running `fstrim` in the guest would reduce the size of QEMU virtual disks. Signed-off-by: Chris Xiao <[email protected]>
I realize this is a couple years late, so you probably don't need this, but if anyone else comes from Google, the current location of diffdisk for me is |
The
diffdisk
starts out small, but grows quickly as users create and delete container images. This can become an issue on laptops with limited free space.I tried to enable trim support just for Alpine, for testing, but couldn't get it to work. Here is the patch I tried:
I've created some files via
dd if=/dev/urandom of=1.bin bs=64M count=64 iflag=fullblock
etc and verified the growth indiffdisk
size.I then deleted the
*.bin
files and ran:But the size of the disk never shrinks.
I wonder if this is a macOS limitation, that qemu doesn't implement the sparse file logic for APFS.
Thoughts?
The text was updated successfully, but these errors were encountered: