Reputation: 3036
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
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...
Upvotes: 5
Views: 11265
Reputation: 3036
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>
Upvotes: 2