By support of WSL (Windows Subsystem for Linux), you can install any Linux distros in a Windows machine. Recommended method from WSL documentation is by downloading the distribution from Microsoft Store or find .appx
installation file available in Microsoft website.
For running multiple instances of same Linux distribution, you can duplicate the data using export-import procedure, as I have mentioned in another post.
Another method that might be more beneficial is by utilizing Docker. Currently, Docker has already had variety of images of Linux distributions in its registry. You can also store your own costumized distribution in Docker registry that can be distributed to any machines instantly.
After you had WSL 2 and an installed Linux distribution from Microsoft Store, you are ready to have more Linux instances in your Windows.
1. List all installed distributions in your Windows.
wsl --list -v
2. Run the distribution you desired from terminal, for example, you have installed Ubuntu-18.04.
wsl -d Ubuntu-18.04
3. Install Docker for Ubuntu by following instruction from Docker Docs.
4. Run Docker service.
service docker start
5. Run a container of any Linux distro that you want to multiply, for example, you want Ubuntu 20.04.
docker run -d ubuntu:20.04
6. List all available containers, and keep the Container ID you previously run.
docker ps -a
You can also run this following command to find the specified Container ID directly.
docker container ls -a | grep -i ubuntu:20.04 | awk '{print $1}'
7. Export container data as a .tar file to mounted volume.
docker export "ContainerID" > "/path/to/exported/ubuntu.tar"
By default, WSL will mount your location where you start Linux with WSL into /mnt/your/location
. If you started Linux with WSL while you were in C:\data
, a volume would be mounted on /mnt/c/data
. For example, the Container ID is 123123abcabc
then your command will be as follows.
docker export 123123abcabc > /mnt/c/data/exported-ubuntu-20.04.tar
Now, the exported file is available in C:\data\exported-ubuntu-20.04.tar
.
8. Quit from Linux and back to Windows terminal, then import previous exported file as a new distribution by setting new name and new data location.
exit
wsl --import newDistroName C:\data\newDistroData C:\data\exported-ubuntu-20.04.tar
Comments
Post a Comment