How can we run an Hyper-V virtual machine, with WSL2?


johnp

Well-known member
Member
Local time
2:06 PM
Posts
28
OS
Manjaro Linux with GNOME desktop environment, Windows 11 Pro with Debian Linux in WSL 2
Hi all,

I have installed and use Ubuntu in WSL2.

Also, I have installed and use Manjaro Linux MATE, in Hyper-V (as a Generation 2 virtual machine, that is the newest option).

Is there any way to run the Manjaro Linux installation of Hyper-V, with WSL2?

Thank you a lot.
 
Windows Build/Version
Windows 11 Version 21H2
Last edited:

My Computer

System One

  • OS
    Manjaro Linux with GNOME desktop environment, Windows 11 Pro with Debian Linux in WSL 2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Build to Order machine
    CPU
    Intel Core i7-4790 (Haswell Refresh)
    Motherboard
    MSI Z97 Gaming 7
    Memory
    32 GB
    Graphics Card(s)
    GIGABYTE NVIDIA GeForce RTX 2060 GAMING OC PRO 6G
    Monitor(s) Displays
    LG 27GN650-B IPS HDR Gaming Monitor 27" FHD
    Screen Resolution
    1080p
    Hard Drives
    2 x Samsung 860 EVO SATA SSD 1TB
    1 x Samsung 870 EVO SATA SSD 2TB
    PSU
    Corsair 1000 Watt
    Case
    Corsair Obsidian Series 750D full tower ATX case
    Cooling
    CORSAIR Hydro Series H80i v2
    Internet Speed
    1 Gbps / 1 Gbps symmetrical FTTH (GPON)
    Browser
    Microsoft Edge
Hi there
Bit confused as to the meaning of this question.

You don't need HYPER-V to install the Linux VM if you want to run a "Native distro" in the WSL. There's no advantage in doing that over a "bog standard HYPER-V VM" at least IMO. Just install the distro from the MS store.

WSL means that this is actually a running "Linux kernel" on Windows - technically not really a VM in the true sense of the word. Ms is using a "modified" linux kernel and has some "customised" distros that will install on it. If you can use the command line you might be able to install other distros - not sure if that's possible currently as you'd need to be able to boot from an iso and get access to the "Linux root disk". It's also not easy to add a desktop GUI either although with a lot of tinkering it can be partly done. Some GUI programs will run however.

This though could be a way if you can get the tar file of the distro


I'm looking to see if there's ways of installing your own distros in the WSL -- have been doing other things lately but now W11 has settled down a bit - might be worth looking at this again.

If anybody has installed "Non Ms store" distros please post on how they did it - and also anybody whose got a full GUI working on WSL.

Cheers
jimbo
 

My Computer

System One

  • OS
    Windows XP,7,10,11 Linux Arch Linux
    Computer type
    PC/Desktop
    CPU
    2 X Intel i7
Hi jimbo45, thank you for your answer.

What I have done so far, is installed the default WSL2 Ubuntu instance.

Then I exported it to a tar file, and imported it as "Ubuntu MATE". Then, using tasksel, I installed the default Ubuntu MATE packages to it, by following this procedure:


It worked fine, when I opened a Windows Terminal with it, I was still viewing the Linux command line, but after installing xrdp in the virtual machine, I could see the GUI by connecting with Remote Desktop Connection client of Windows 11.

So, the situation was like this:

I had Ubuntu MATE with its GUI installed in WSL2, and was using it well with Windows Terminal.

Later, I erased the Ubuntu MATE WSL2 installation, and installed Manjaro MATE in Hyper-V.

The question is, can I use the Manjaro MATE Hyper-V virtual machine with WSL2, i.e. use its command line in Windows Terminal?

I will study the How-to guide you provided, it looks like it is in the right direction.
 
Last edited:

My Computer

System One

  • OS
    Manjaro Linux with GNOME desktop environment, Windows 11 Pro with Debian Linux in WSL 2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Build to Order machine
    CPU
    Intel Core i7-4790 (Haswell Refresh)
    Motherboard
    MSI Z97 Gaming 7
    Memory
    32 GB
    Graphics Card(s)
    GIGABYTE NVIDIA GeForce RTX 2060 GAMING OC PRO 6G
    Monitor(s) Displays
    LG 27GN650-B IPS HDR Gaming Monitor 27" FHD
    Screen Resolution
    1080p
    Hard Drives
    2 x Samsung 860 EVO SATA SSD 1TB
    1 x Samsung 870 EVO SATA SSD 2TB
    PSU
    Corsair 1000 Watt
    Case
    Corsair Obsidian Series 750D full tower ATX case
    Cooling
    CORSAIR Hydro Series H80i v2
    Internet Speed
    1 Gbps / 1 Gbps symmetrical FTTH (GPON)
    Browser
    Microsoft Edge
I read the How-to guide, it is about exporting Docker containers to a tar file.

I have no clue how to do the export of Manjaro MATE Hyper-V virtual machine, to a tar file.
 

My Computer

System One

  • OS
    Manjaro Linux with GNOME desktop environment, Windows 11 Pro with Debian Linux in WSL 2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Build to Order machine
    CPU
    Intel Core i7-4790 (Haswell Refresh)
    Motherboard
    MSI Z97 Gaming 7
    Memory
    32 GB
    Graphics Card(s)
    GIGABYTE NVIDIA GeForce RTX 2060 GAMING OC PRO 6G
    Monitor(s) Displays
    LG 27GN650-B IPS HDR Gaming Monitor 27" FHD
    Screen Resolution
    1080p
    Hard Drives
    2 x Samsung 860 EVO SATA SSD 1TB
    1 x Samsung 870 EVO SATA SSD 2TB
    PSU
    Corsair 1000 Watt
    Case
    Corsair Obsidian Series 750D full tower ATX case
    Cooling
    CORSAIR Hydro Series H80i v2
    Internet Speed
    1 Gbps / 1 Gbps symmetrical FTTH (GPON)
    Browser
    Microsoft Edge
I read the How-to guide, it is about exporting Docker containers to a tar file.

I have no clue how to do the export of Manjaro MATE Hyper-V virtual machine, to a tar file.
Hi there

@johnp

I'm 100% not sure about this but I don't think you can convert a HYPER-V VM into a WSL version You can create Manjaro Mate WSL easily enough though. I'm not sure why you would want to convert a HYPER-V machine into a WSL version either -- remember that currently WSL machines can't be accessed from OUTSIDE their host due to the Virtual network being NAT and not Bridged. hyper-V vm's can be accessed remotely (bit of a fiddle with Networking but Kari's tutorials are always good on that one).

However there should be NO problem with accessing a HYPER-V Linux VM's terminal from Windowss -- the simplest is to do the following

1) On Windows install in the extra options the openssh server and ensure the service is running

2) On yourHYPER-V Linux VM ensure open ssh is installed and the ssh server is running (might be called sshd in some distros -the final d often signifies that a daemon is running, and enable and start the service (ssh / sshd depending on your distro. You might also want to enable "Root access for SSH" in the config, and if you need the GUI you can also mess around with X-Server over SSH but I wouldn't bother with that if XRDP works.

3) from Windows command line simply type SSH to your VM.

(Not sure if this works but it could also in some circumstances -- enable in "turn Windows features off and on" and select telnet. then you can also as an alternative telnet nto your VM. Personally I prefer the ssh method.

For Dockers you can install the Docker interface on Windows which makes it easy to "Pull" versions, create containers, import and export to .tar files etc.

Cheers
jimbo
 
Last edited:

My Computer

System One

  • OS
    Windows XP,7,10,11 Linux Arch Linux
    Computer type
    PC/Desktop
    CPU
    2 X Intel i7
After about two months from the last post in this thread, now I am using WSL 2 extensively, and I know a lot more about it.

Virtual machines with Linux, either with command-line only, or with installed desktop environments that run on X.Org or Wayland, can not be used in WSL 2, because:

WSL 2 provides its own Linux kernel, a Wayland compositor named Weston, XWayland for running X.Org programs, and a PulseAudio server.

Linux distributions running in WSL 2, are in container form only, they can not have their own Linux kernel, and must not run their own X.Org server, Wayland compositor, or PulseAudio server.

Linux containers provided in:

linux containers

are very suitable to run in WSL 2.

A Windows program named Distrod:

distrod

can download and convert Linux containers from that site, to WSL 2 containers, automatically.

You just run the distrod_wsl_launcher.exe, and you get a list with the available Linux containers:

s.png


These WSL 2 containers, run systemd, in contrast with the Microsoft Store official Linux containers, that do not.

When you want to install a GUI program in a WSL 2 Linux instance (container), in Windows 11, so as to run it from the Windows 11 Start menu, you just install the application itself directly, and not a desktop environment.

Assuming you have an Ubuntu instance, an example:

sudo apt install firefox


Another useful information:

Prefer the Microsoft Store installation of WSL 2 itself, in Windows 11, because it gets updated more frequently, together with the latest versions of WSL 2 Linux kernel and WSLg.

s2.png

For more information, refer to:

WSL 2 in Microsoft Store

Using Distrod, I have installed Arch Linux container in WSL 2:

s3.png

I suggest to begin with an Ubuntu instance (container), or some other Linux distribution you know how to use, to get accustomed to WSL 2.


Useful links:

WSL 2 site:

Releases · microsoft/WSL
GitHub - microsoft/WSL: Issues found on WSL


WSL 2 Linux kernel site:

Releases · microsoft/WSL2-Linux-Kernel
GitHub - microsoft/WSL2-Linux-Kernel: The source for the Linux kernel used in Windows Subsystem for Linux 2 (WSL2)


WSLg (it allows to run GUI Linux programs like Firefox in Windows 11, together with Windows 11 Start menu integration):

GitHub - microsoft/wslg: Enabling the Windows Subsystem for Linux to include support for Wayland and X server related scenarios


WSL 2 installation from the Microsoft Store, instead of installing it from within Windows 11:

A preview of WSL in the Microsoft Store is now available! - Windows Command Line


Distrod:

Releases · nullpo-head/wsl-distrod

GitHub - nullpo-head/wsl-distrod: Distrod is a meta-distro for WSL 2 which installs Ubuntu, Arch, Debian, Gentoo, etc. with systemd in a minute for you. Distrod also has built-in auto-start feature on Windows startup and port forwarding ability.
 
Last edited:

My Computer

System One

  • OS
    Manjaro Linux with GNOME desktop environment, Windows 11 Pro with Debian Linux in WSL 2
    Computer type
    PC/Desktop
    Manufacturer/Model
    Build to Order machine
    CPU
    Intel Core i7-4790 (Haswell Refresh)
    Motherboard
    MSI Z97 Gaming 7
    Memory
    32 GB
    Graphics Card(s)
    GIGABYTE NVIDIA GeForce RTX 2060 GAMING OC PRO 6G
    Monitor(s) Displays
    LG 27GN650-B IPS HDR Gaming Monitor 27" FHD
    Screen Resolution
    1080p
    Hard Drives
    2 x Samsung 860 EVO SATA SSD 1TB
    1 x Samsung 870 EVO SATA SSD 2TB
    PSU
    Corsair 1000 Watt
    Case
    Corsair Obsidian Series 750D full tower ATX case
    Cooling
    CORSAIR Hydro Series H80i v2
    Internet Speed
    1 Gbps / 1 Gbps symmetrical FTTH (GPON)
    Browser
    Microsoft Edge
Ideally? You should not have both Hyper-V and WSL2 as plausible enabled installations on your local Windows 11 machine.
 

My Computer

System One

  • OS
    Windows 11
Back
Top Bottom