microsoft / WSL

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

WSL destroys home directory without warning after system restore #6105

Open rollant opened 4 years ago

rollant commented 4 years ago

Environment

Windows build number: Microsoft Windows [Version 10.0.18363.1082]
Your Distribution version: Ubuntu 20.04
Whether the issue is on WSL 2 and/or WSL 1: Linux version 4.4.0-18362-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #1049-Microsoft Thu Aug 14 12:01:00 PST 2020

Steps to reproduce

I use Ubuntu launcher from Microsoft store. After I restored system to earlier state due to unrelated problem with recent update, I tried to launch WSL and got message "please wait, installing...". Then I was asked to create an user and afterwards I ended up in empty home directory.

WSL logs:

Expected behavior

WSL should warn people that their installation is unusable and has to be reinstalled, so they'll have a chance to recover any data they may have had in WSL

Actual behavior

My data was overwritten without a warning.

I also noticed that while /home directory was recreated during reinstallaton, some other directories were created long time ago (see screenshot).

wsl
licanhua commented 4 years ago

WSL save all distros' Registration in regkey. If you lost those keys, it's nearly impossible for new user to recover it.

If the distribution is not registered with WSL, register it. Registration extracts the tar.gz file that is included in your distribution appx.

Because you restored Windows to a point where you didn't install the distro(because it doesn't have registration), so it extracts the tar and re-install it.

WSL provides --import and --export, which are reliable method to handle system restore.

Agree it's a nice feature if we can warning the user before overwrite the linux.

rollant commented 4 years ago

Actually, I can live with having to reinstall the system, but there were few files in my home directory I wish I had a chance to recover first

therealkenc commented 4 years ago

Ref #5261