Skip to content
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

Can't upgrade to WSL2 #4717

Closed
ctotogo opened this issue Nov 27, 2019 · 27 comments
Closed

Can't upgrade to WSL2 #4717

ctotogo opened this issue Nov 27, 2019 · 27 comments

Comments

@ctotogo
Copy link

ctotogo commented Nov 27, 2019

Hello ---

Have been running WSL for a while. Finally getting around to upgrading to WSL 2 and I'm being told that my distribution doesn't support WSL 2. Here's what I'm seeing.

PS C:\WINDOWS\system32> wsl --list --verbose
NAME STATE VERSION

  • Legacy Running 1

PS C:\WINDOWS\system32> wsl --set-version Legacy 2
Conversion in progress, this may take a few minutes...
For information on key differences with WSL 2 please visit https://aka.ms/wsl2
The Legacy distribution does not support WSL 2.

Running Ubuntu 19.04 which I upgraded to within Ubuntu itself.

Any ideas on how to move forward -- other than I hope not having to reinstall everything :/ Got it configured just the way I like it.

Thanks so much in advance.
Carlos Abreu

@sirredbeard
Copy link
Contributor

sirredbeard commented Nov 27, 2019

What could prompt the message The Legacy distribution does not support WSL 2. @craigloewen-msft?

@craigloewen-msft
Copy link
Member

It seems like you're using the version that was shipped back when WSL was just Bash On Ubuntu On Windows.

Could you try running wsl --export Legacy ./ubuntu.tar and then using import to import it back in as a WSL 2 distro: wsl --import <DistroName> <InstallLocation> <FileName> --version 2. DistroName is what you'd want to refer to the new distro as (i.e: what shows up in wsl -l installlocation is where the installed files will live, and FileName is a path to the ubuntu.tar file you created when exporting.

@Biswa96
Copy link

Biswa96 commented Nov 27, 2019

There are two possible ways.

  • First check if wsl.exe --help shows a --export options. If yes then export the installed distribution to a tar file. For example the command will be: wsl.exe --export Legacy myfile.tar. Then uninstall the Legacy distribution with wsl.exe --unregister Legacy command. And reinstall the distribution with wsl.exe --import command.

  • Or run the Legacy distribution and tarball the whole distribution, see this answer. Then uninstall Legacy distribution and reinstall it from that tarball.

@sirredbeard Because the "Legacy" distribution uses LxFs i.e. old NTFS extended attributes but the new WSL1 distribution uses WslFs i.e. new NTFS extended attributes. Remember there was an option wslconfig.exe /upgrade :)

@sirredbeard
Copy link
Contributor

@craigloewen-msft @Biswa96 Ah, the Legacy distribution. Thank you for reminding me about that.

@ctotogo
Copy link
Author

ctotogo commented Nov 27, 2019

Thanks so much. The moment I saw anything about WSL I installed it and have been using it ever since. Exactly what I was looking for. Haven't had to change it until now because some Docker madness. I see the export option. Down the rabbit hole....

@ctotogo
Copy link
Author

ctotogo commented Nov 27, 2019

So the export worked. Unregistering Legacy worked. The import failed(twice now) a little while after it starts with the message:

"The specified network name is no longer available."

I can see it starts to write to a file in the install directory named "ext4.vhdx" but by the time it fails it's deleted it.

Thoughts?

@Biswa96
Copy link

Biswa96 commented Nov 27, 2019

Try to import it as WSL1 with --version 1 option, then convert it to WSL2 with --set-version option.

@ctotogo
Copy link
Author

ctotogo commented Nov 27, 2019

I ran it in elevated cmd.exe and it worked :) Thanks though. Let's see how it looks now.

@ctotogo
Copy link
Author

ctotogo commented Nov 28, 2019

Anyway, so the cmd.exe install went too fast. I get this when I try to start WSL.

The remote procedure call failed.

So I unregistered that and tried installing as @Biswa96 suggested. It imported fine -- took much longer, which I interpreted as a good sign.. The upgrade didn't complain. Starting it though failed with the same reason.

The remote procedure call failed.

I see mention of that error elsewhere, but there doesn't seem to be a fix yet. Any thoughts?

@ctotogo
Copy link
Author

ctotogo commented Nov 28, 2019

Downloading the latest Windows build 19033.1 - not sure if it will do anything, but hey, I'm grasping at straws.

@ctotogo
Copy link
Author

ctotogo commented Nov 28, 2019

That worked. Thanks all for your help.

@ctotogo ctotogo closed this as completed Nov 28, 2019
@bissim
Copy link

bissim commented Feb 6, 2020

@ctotogo Hello, in order to export user data as well (the ones in /home folder) do I need to perform wsl --export in a privileged command line?

Moreover, when importing, does destination distribution need to be initialized? I assume it doesn't.

@Biswa96
Copy link

Biswa96 commented Feb 6, 2020

wsl.exe --export packs up all folder in the installed distribution.

In the second question, what do you mean by "initialize"?

@bissim
Copy link

bissim commented Feb 6, 2020

Hello @Biswa96 and thank you for your answer.

I'm trying to export all data from Legacy distribution into an Ubuntu one, but my first attempt pruned user folder in /home; so, I wondered whether they could be exported by exporting from a privileged command line.

About my second question, I'd like to know whether I have to set up the new distribution before importing data or not.

@Biswa96
Copy link

Biswa96 commented Feb 6, 2020

Interesting... I will try to reporduce that issue. The imported distribution will be as it is before.

@bissim
Copy link

bissim commented Feb 6, 2020

By the way, is there any official guide to migrate from Legacy and keeping all user programs and data?

@Biswa96
Copy link

Biswa96 commented Feb 6, 2020

Upgrading a distribution is not in WSL realm. I would just move/copy the whole normal user and root user home folder. Then install packages which is previously installed.

@bissim
Copy link

bissim commented Feb 6, 2020

As I stated above, I have to migrate my user from Legacy, not upgrade a distribution. Reinstalling everything is extactly what I don't want to do.

@eugenesvk
Copy link

As I stated above, I have to migrate my user from Legacy, not upgrade a distribution. Reinstalling everything is extactly what I don't want to do.

Not sure if it's still relevant to you, but I also had this issue where the wsl --export command pruned my home folder (it was empty). I'm glad that I didn't trust their process and verified the content of the resulting Legacy.tar file to discover it misses the most important thing — my files!!!

To avoid the disaster of losing all my files I followed this guide to create manual tar archives for my /home/ folders that I restored after I --export'ed and --import'ed the distribution, but not before I finally managed to wsl --upgrade it and also had to fix another bug with the default username with this awesome utility https://github.com/DDoSolitary/LxRunOffline (this utility also has an option to export/import, but I haven't tried it, you may try it to see if it exports the /home/ folder properly)

Accidentally, after the export/import/upgrade I've tried to export it again, and this time the .tar file had the full home folder as well, so maybe they botched the --export process only for the legacy LxFs distributions?

@benhillis
Copy link
Member

Correct, export does not traverse mounts and in the Legacy distro the home folder is a separate mount. I suggest backing it up separately.

@eugenesvk
Copy link

@benhillis would be nice if any of the docs re. the --export option mentioned such a critical omission as well as suggested the way to back it up

@black-snow
Copy link

Followed the wsl import/export approach => home is gone :|

@VonC
Copy link

VonC commented Jun 1, 2020

@black-snow Following https://superuser.com/questions/1185033/what-is-the-home-directory-on-windows-subsystem-for-linux, you can still get your home files in (for initial WSL bash version) %LOCALAPPDATA%\Lxss\rootfs\home\<user>.

For WSL1 distributions installed from the Windows Store: %LOCALAPPDATA%\Packages\...\LocalState\rootfs

Even after a complete export/import and unregister, I still managed to find my home files (in my case, an old WSL1 bash image) in C:\Users\vonc\AppData\Local\lxss\home\vonc

@black-snow
Copy link

@VonC thanks, but there is no such folder. Nvm, I go from scratch.

@nlienard
Copy link

thanks, i had same issue. i did export, then import and it works. it converted into version 2.

@mcclure
Copy link

mcclure commented May 10, 2022

IMO the 2019 @Biswa96 comment above is actively dangerous and should be edited, to warn people should read this entire thread before running the suggested command. :(

(Yes, I realize I was probably a fool to run a command with --unregister in it without thinking the implications through fully. But apparently I am a fool because I did it and suffered as a result. I was able to recover my /home files, eventually, using VonC's method, but all my permissions and symlinks are now messed up.)

Short version for any remaining Legacy users finding this thread:

  1. The --import/--export process described above will probably not result in an immediately working distribution, I suggest do not run the --unregister command until your new converted distro has been tested and you are certain it works as desired.
  2. You may not want to upgrade to WSL2 at all, actually. As soon as my torturous upgrade from Legacy to WSL2 was finished, I immediately downgraded to WSL1 because of the file speed issue.

@Dani21
Copy link

Dani21 commented Jul 8, 2022

This left out the home directory for me too. I would've lost all my user data, if it wasn't for @VonC.

Can @Biswa96 or @craigloewen-msft PLEASE edit your responses to make a note of this?? Making no mention of this is dangerous. I did verify all my data was exported, but didn't pay attention to the /home folder.

Here's what I did to fix it after importing:

[in WSL]
cd /home
cp -prf /mnt/c/Users/<account>/AppData/Local/lxss/home/<account2> .

[set permissions]
chmod -R 640 <account2>/
find <account2>/ -type d -print0 | xargs -0 chmod 750
chown -R <account2> <account2>/

[change default user]
echo "[user]
default=<account2>" >> /etc/wsl.conf
exit

[outside of WSL]
wsl -t <distro>
wsl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests