This message was deleted.
# rancher-desktop
a
This message was deleted.
f
There is no way to reclaim the disk space on the host side, but if you delete images, then that space will be re-used when you fetch or create additional images.
The data volume of the VM is essentially a sparse file, that is 100GB in size, but only the used blocks are allocated. But once you write to any block, the disk space on the host filesystem is committed, and there is no way free that again, except by deleting the file and creating a new sparse file.
Is there a way to specify disk size for VM on Mac M1? · Issue #1521 · rancher-sandbox/rancher-desktop shows a workaround to modify the max size of the data volume (at the time of creation). You could use this to specify a smaller size, so you get an "out of space" error on the data volume instead of it growing to 100GB.
e
Thanks @fast-garage-66093 btw I am on Windows 10.. And I only noticed that the space got freeup when I reset factory the rancher desktop. I am thinking if there is other way to do that by not reset factory?
f
Unfortunately there is no other way right now. Well, besides making sure to regularly prune old/unused image before the volume grows too much. But there is no other way to reclaim the disk space once the volume has grown; you have to make space available to be reused to prevent additional space from being allocated.
👍 1
e
w
One method for pro/ultimate level windows is the optimize-vhd cmdlet in powershell. make sure that Rancher is shutdown and target the ~\Appdata\Local\rancher-desktop\distro-data\ext4.vhdx
in Home you can shrink them using diskpart, but just takes a bit more work
e
Yup sadly I'm on enterprise so not applicable. Thanks still Justin
f
Enterprise edition should include
optimize-vhd
as well (it is a Hyper-V tool), so you should have it
👍 1
e
I already tried it but its not being recognize with my powershell.. Or do I miss something?
f
I just found How to Shrink a WSL2 Virtual Disk – Stephen's Thoughts. I obviously haven't tried it, and don't know if it is save, but you may want to give it a read
e
Yup I also tried that article but didnt work. Maybe for now, I don't have any option but to do factory reset just to free up space
f
So what happened when you tried the approach in the article? Did you get an error, or did it just not shrink the file? Are you sure you have significant empty space on the volume by deleting images first?
e
No error it says 100% completed after compact vdisk but when I checked my drive for my WSL distro (Ubuntu 20.04) it didnt shrinked
f
Did you check the free space on the host disk itself?
e
Yes nothing changed
f
Too bad. It sounded promising as several commenters confirmed that the procedure worked for them too.
e
Yeah anyway thanks for helping me @fast-garage-66093
Hopefully soon Racher Desktop will have that feature that will automatically remove tangled/unused images
f
You mean like running
docker image prune
or
docker image prune -a
on a schedule?
I don't think we would add that; this seems to be something best left to the user. What I would like to figure out would be install the data volume initially with a smaller maximum size, so you get an out-of-disk-space error when creating more images instead of filling up the host disk,
👍 1
Did you run
wsl --shutdown
again after
compact
? Or maybe even reboot?
e
Yup I run shutdown first before doing other steps
f
I would still try to reboot once, if you haven't done so, just to see if it makes a difference. The old space may still be kept allocated by some process/service in memory. It's grasping a straws, but there seems little else left to do...
e
Ahh you mean reboot.. yes I've done that as well but nothing happens
f
Another thing to try: Run
sudo fstrim /
inside the
rancher-desktop
distro after deleting images, but before running
diskpart
or
compact
.
👍 1
Hmm, not sure if we include
fstrim
in the Alpine distro; let me do some checks
It doesn't work for me on macOS; will check on Windows
It does not throw an error on Windows:
wsl -d rancher-desktop fstrim /
You may need to run
wsl -d rancher-desktop fstrim /var/lib
instead
Because that is the mount point on which the data volume is mounted, and where the images are stored
I have to drop now; but please let us know if you got things working!
e
Ok I will try that again. Thanks @fast-garage-66093 🙂
f
I suspect you didn't shutdown wsl before running the
compact
w
yup close RD so that distro is not running or just wsl --shutdown to down them all. And you may need to check if you just have the Hyper-V feature enabled or only Windows Hypervisor Platform. I would imagine that cmdlet will need the Hyper-V “management” parts in addition to the core platform feature that WSL2 depends on.
2161 Views