rancher-sandbox / rancher-desktop

Container Management and Kubernetes on the Desktop
https://rancherdesktop.io
Apache License 2.0
6.01k stars 283 forks source link

Specify Storagelocation for vhdx files on Windows #1609

Open containerguy opened 2 years ago

containerguy commented 2 years ago

Problem Description

Currently we are not able to specify a different location for storing distro data, which results in storing all virtual hard disks (.vhdx) in the users profile. This leads to quite big storage allocation on our root disk, which can cause some trouble when handling big container images / instances like SAP stuff.

Proposed Solution

It would be great to specify a different location for storing the virtual hard disks. This could be an additional or external hard drive with fallback to home profile, if necessary.

Additional Information

I searched the issue tracker and found #369 and #298 but it seems not to complete match this request for Windows based systems.

Preflight Checklist

jandubois commented 2 years ago

I think this is a duplicate of #369.

There is a way to do this on macOS/Linux by moving the lima directory and replacing it with a symlink. But since the description mentions "user profile", I assume this is about Windows, and I can't think of a workaround for it there.

containerguy commented 2 years ago

Yes, it's about windows systems in this issue.

raff-run commented 2 months ago

@jandubois This isn't a duplicate of #369 because that issue is about moving the VM, and this isn't about that, it's about making the file %localappdata%\rancher-desktop\distro-data\ext4.vhdx exist somewhere else where the user chooses by default, without "wsl export, unregister, wsl import" workarounds.

This is completely under rancher-desktop's control, because the path %localappdata%\rancher-desktop\distro-data is provided by rancher desktop itself right here: https://github.com/rancher-sandbox/rancher-desktop/blob/c5c382f6168358d93700f937e17f0a6a133f769e/pkg/rancher-desktop/backend/wsl.ts#L397 image

These paths come from here. What this issue is all about is: letting both of these paths be configurable during installation. https://github.com/rancher-sandbox/rancher-desktop/blob/c5c382f6168358d93700f937e17f0a6a133f769e/src/go/rdctl/pkg/paths/paths_windows.go#L36 image

By doing so, we avoid the problem of rancher desktop's completely undoing the workaround and possibly making the user run out of space on their root disk (happened to me just yesterday after I disabled kubernetes lol) every time it decides to upgrade the distro: in backend/wsl.ts image

raff-run commented 2 months ago

Oh, my bad @jandubois, I just realized I was too focused on the problem and realized I specified something that was never specified: the path choice doesn't need to be in the installer. Being a configuration in rancher-desktop's preferences works just as well and, now that I think about it, is more intuitive: you don't need to uninstall/reinstall, having to do the workaround, to not lose data.

From what I can read in the code, if the path changes wsl.ts start() method runs again, rancher-desktop will move the files for us without losing any data: https://github.com/rancher-sandbox/rancher-desktop/blob/c5c382f6168358d93700f937e17f0a6a133f769e/pkg/rancher-desktop/backend/wsl.ts#L1188