4

I recently moved my wsl directory to another drive due to low storage in C: drive. As per the answer provided in this StackOverflow post, I used lxrunoffline tool and moved my Ubuntu distribution to another drive (E:\wsl in my case). As soon as the distribution was moved successfully, I ran wsl to test and it worked like a charm.

Everything went fine until one day I accidentally renamed the E:\wsl folder to something else. Well, as expected, wsl didn't work. Then, I reverted back to the name wsl and expected it to work but to my surprise, it didn't find any installed distribution after that even though it's installed...

E:> wsl
Windows Subsystem for Linux has no installed distributions.
Distributions can be installed by visiting the Microsoft Store:
https://aka.ms/wslstore

Ubuntu installed

Is there any way to revert back to the old directory or make wsl point to a manual location?

EDIT: I don't want to reset Ubuntu as I want to retain the installed packages and preferences...

Melvin Abraham
  • 2,870
  • 5
  • 19
  • 33

1 Answers1

1

Well, I finally found a solution to this problem.

This is as simple as registering the distribution using lxrunoffline tool using the rg or register command.

E:\LxRunOffline\LxRunOffline-v3.3.3>lxrunoffline rg
[ERROR] the option '-d' is required but missing

Options:
  -n arg                Name of the distribution
  -d arg                The directory containing the distribution.
  -c arg                The config file to use. This argument is optional.

After running the register command, I was able to start wsl as usual. But that would log you in as a "root" user and would thus start in "/root" directory. I ran the following command to start wsl as different user (this is for Ubuntu):

ubuntu config --default-user <user-name>
Melvin Abraham
  • 2,870
  • 5
  • 19
  • 33
  • where you downloaded lxrunoffline tool – Sathiamoorthy Sep 12 '20 at 08:06
  • @Shakthifuture https://github.com/DDoSolitary/LxRunOffline. Anyway, many new features have come to the `wsl` CLI over the course of time. I would suggest you to check those out as well... – Melvin Abraham Sep 12 '20 at 08:12
  • I am facing the same problem, ubuntu i have installed. Enabled VM and subsystem, installed wsl still i am ubuntu not showing when use "wsl -l -v" command. – Sathiamoorthy Sep 12 '20 at 08:20
  • If it possible, please answer my question https://stackoverflow.com/questions/63858461/windows-subsystem-for-linux-has-no-installed-distributions-even-i-installed-ub – Sathiamoorthy Sep 12 '20 at 08:39
  • You can install lxrunoffline via PowerShell with Chocolatey using this command choco install lxrunoffline (you will need to install Chocolatey using PowerShell if its not present follow this link: https://chocolatey.org/courses/installation/installing?method=install-from-powershell-v3) – Trevor Oct 02 '20 at 09:26