32

I have WSL 2 installed on my Windows 10 machine. I switched over to version 1 and upgraded from Ubuntu 18.04 to 19.04 using the do-release-upgrade command. I then tried to switch over to WSL 2, but I noticed the output of wsl -l -v is Ubuntu 18.04, not 19.04, but when running an Ubuntu prompt the output of lsb_release -a is accurately 19.04. I then tried moving the distro as named over to WSL 2 anyway, and received a

Exporting the distribution failed.
bsdtar: Write error

error. I am hoping that updating the name to the actual distro (19.04) will solve this issue. Any idea on how to do that? Probably it's in some config file for WSL?

Caecidas
  • 421

3 Answers3

31

If you want to rename your WSL distro, you have to:

  1. Stop all instances of WSL
  2. Open Registry Editor and go to HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Lxss
  3. Find the distro you want to rename, look for the DistributionName
  4. Change it as you want
  5. Start WSL again, you can also execute wsl.exe -l -v to check if it changes
11

(1): Open the Windows registry editor (regedit), and paste the following URI in its adddress bar:

Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss

(2): In the left-side navigation pane, examine folders that look like this {xxxxxxxx-yyyy-xxxx-yyyy-xxxxxxxxxxxx}. (The folder name contains all Hexadecimal digits). Double-click each one until you find the wsl distribution with the name you want to change.

(3): In the right-side navigation pane, double-click the REG_SZ item called DistributionName, and edit its content to whatever you want. Save it.

(4): Finally, restart wsl.

  • Press: Win + R on your PC.
  • Type services.msc into the search box that pops up.
  • In Services Manager tool that pops up, find the first LxssManager entry in the list, and restart it.

That should do it.

NOTE: Do not skip step (4), because doing so will cause some wsl applications launch with errors. For example, Visual Studio Code will not launch correctly because wsl has not been refreshed / restarted.

PS: Don't forget to edit the launch property of your application launch icons. Any of them specifying the -d distroName option to wsl.exe [...] or wslg.exe [...] will need to be edited.

nmvega
  • 671
5

Just ran into this myself. Though it's basically just cosmetic and only comes up when running WSL specific commands, I wanted to keep things from getting confusing in the future.

What I ended up using LxRunOffline to duplicate my Distro, which in the process allows you to name the duplicate, setting the duplicate as default, and then uninstalling my old Distro.

Example of what I did(ran in powershell from my user's home directory):

#List installed Distros
LxRunOffline.exe l
#Duplicate Ubuntu-18.04 to folder in my user directory and name it Ubuntu
LxRunOffline.exe d -n Ubuntu-18.04 -d ./WSL/Ubuntu -N Ubuntu
#Set new Distro as default
LxRunOffline.exe sd -n Ubuntu
#Uninstall old Distro
LxRunOffline.exe ui -n Ubuntu-18.04

PS: To be clear, the WSL listed name of your Distro is unrelated to what is really running inside the Distro. So you just have to use the current name WSL currently lists, in the WSL2 convert command.

japzone
  • 291