microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.25k stars 811 forks source link

WSL should at least very verbosely warn that distro unregister will destroy /home #8466

Open blami opened 2 years ago

blami commented 2 years ago

Is your feature request related to a problem? Please describe. Currently if you wsl.exe --unregister a distro on WSL2 (did not test behavior on WSL1) all files on .vhd with its root filesystem will be gone too. As people usually keep their e.g. source code, configs, notes, etc. inside the .vhd because of native ages unresolved host filesystem slowness it would be great if wsl.exe gave more verbose warning about that than blurry Unregisters the distribution and deletes the root filesystem description (had to explain to someone who lost all their work that root filesystem is literally / and /home was on it).

C:\> wsl.exe --help
...
    --unregister <Distro>
        Unregisters the distribution and deletes the root filesystem.
...
C:\> wsl.exe --unregister Ubuntu
C:\> Unregistering...
C:\>

Describe the solution you'd like I'd at least want to get verbose prompt (skippable with --force)

C:\> wsl.exe --help
...
    --unregister <Distro>
        Unregisters the distribution and irreversibly deletes all files on its filesystem.
...
C:\> wsl.exe --unregister Ubuntu
This will irreversibly remove Ubuntu and all its files, are you sure (Y/N): ...

Ideally, there should be an additional options for wsl.exe to:

Describe alternatives you've considered

Additional context As WSL2 grows more and more popular, UX should be smooth and without unexpected surprises. Nowadays not everyone who uses Linux knows what root filesystem is and what consequences has deleting one.

Robula commented 2 years ago

Just having the ability to keep /home as a separate VHD would be greatly beneficial. Whilst we can already do this this wsl --mount --vhd it is not possible to have the VHD automatically mount when WSL starts. See https://github.com/microsoft/WSL/issues/8070

tusharsnx commented 1 year ago

somewhat similar but if I --unregister a distro installed with --import-in-place, wsl deletes the vdhx while unregistering the distro. Instead, I'd expect it to leave vdhx as it is.

--unregister need to have a confirmation before it does its thing.