Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you install multiple, separate instances of Ubuntu in WSL? [closed]

In Windows 10, how do you install multiple, separate instances of Ubuntu in WSL? I'd like separate instances for different work spaces. For instance one for Python development, one for Ruby development, one for .Net Core development, etc. I know I could jam all of these into the same Ubuntu on WSL instance, but I'd rather have a separate one for each of these scenarios. Is this possible?

like image 326
MattSlay Avatar asked Jul 29 '18 21:07

MattSlay


People also ask

Can I have multiple Linux on wsl?

Windows Subsystem for Linux (WSL) allows you run a Linux enviroment on Windows, using your favourite Linux distribution. You can even install multiple types of distributions side-by-side. However, there is no out-of-the-box way to install multiple instances of the same distribution.

What is a wsl instance?

WSL is a free download and enables you to run native Linux command line tools directly on Windows, alongside your traditional Windows desktop, without the overhead of a virtual machine. By installing WSL, you can use a native Linux environment to connect to your Linux EC2 instances instead of using PuTTY or PuTTYgen.

How do I change distros in wsl?

Set default Linux distro on WSL2Search for Command Prompt, right-click the top result, and select the Run as administrator option. Quick tip: You can also write the command like this: wsl -l . In the command, replace DISTRO-NAME for the name of the distro to set it as default (see step No. 3).


1 Answers

The newer wsl command's import/export feature can readily create copies of a distro without installing any additional tools or using RegEdit. For example

cd C:\Users\MattSlay wsl --export Ubuntu ubuntu.tar wsl --import UbuntuRuby .\UbuntuRuby ubuntu.tar wsl --import UbuntuPython .\UbuntuPython ubuntu.tar wsl --import UbuntuDotNet .\UbuntuDotNet ubuntu.tar wsl -d UbuntuRuby 

wsl -d <distro> launches the distro. If WSL 2 has been installed, then the distro can be converted between versions during --import using the --version option:

wsl --import UbuntuRuby .\UbuntuRuby ubuntu.tar --version 2 

A smaller distro, such as Alpine, can make experimentation much faster. Finally, wsl --import can read from standard input - and wsl --export can write to standard output -. This allows a compression program to be used to save disk space if desired.

like image 98
M. Warren Avatar answered Oct 03 '22 12:10

M. Warren