Score:11

Is there an alternative of WSL for Ubuntu?

ug flag

Windows now has a subsystem for Linux, where you can try different distros as an application. With no virtual machine needed. Is there something like that on Linux?

ru flag
Are you asking how to do this in Ubuntu, or on Linux in general? If you 're asking for linux in general, we're going to redirect you to https://unix.stackexchange.com/ because this site is for Ubuntu only.
Ya Y avatar
ug flag
@Thomas Ward first of all for Ubuntu.
Nmath avatar
ng flag
*"you can try different distros as an application"* - eh, not really... WSL still doesn't officially support desktop environments and has only limited support for GUI applications. I would not consider WSL to be a useful method to try different Linux distributions.
muru avatar
us flag
What is the alternative supposed to do? What feature set are you actually looking for?
Tanner Swett avatar
au flag
It sounds like you're asking if there's a sort of "Linux Subsystem for Linux," right?
somebody avatar
al flag
@Nmath wsl has had quite good support for GUI applications for years (ever since 2015 probably) - via VcXsrv
somebody avatar
al flag
vaguely related: [bedrock linux](https://bedrocklinux.org/) - rather than trying different distros, it lets you have a single distro with parts of other distros added in. huge disclaimer though that you should absolutely not hijack your main distro if you're not prepared for things to go wrong. not that things *will* go wrong... but, well, getting different distros to behave together is complicated
Esther avatar
es flag
"no virtual machine needed" isn't really true either; since WSL2 it's just running on a behind-the-scenes Hyper-V platform.
raj avatar
cn flag
raj
@Esther WSL2 yes, but as far as I know WSL1 is just a POSIX compatibility layer on top of Windows kernel, and there is a minimal Ubuntu distro (consisting of only userland utilities without the kernel) that makes use of this POSIX-compatible Windows kernel...
us flag
I've been using Debian (sorry!) + LXDE on WSL1 and WSL2 using VNC for years now. Much more lively on WSL2.
jeancallisti avatar
no flag
What you're asking for is an equivalent, not an alternative. Please change your question's title accordingly: "Is there an equivalent of WSL for Ubuntu?"
C.S.Cameron avatar
cn flag
Have you tried **QEMU** in Ubuntu?
Score:26
vn flag

First, it's always going to be a richer and more "real" experience if you try out a distribution on a VM, but ...

With no virtual machine needed. Is there something like that on Linux?

Sure, the techniques that WSL 2 use are available to pretty much any Linux OS, with similar caveats and limitations.

Keep in mind that, as @UtkarshChandraSrivastava mentioned in this answer, WSL 2 really is running in a VM.

The distribution that is running inside WSL 2, however, is running in a namespace/container. Each running distribution has a different:

  • PID namespace
  • Mount namespace
  • IPC namespace
  • UTS namespace
  • WSLg System Distribution

However, they all share the following with the parent WSL2 VM (and thus each other):

  • User namespace
  • Network namespace
  • Cgroup namespace
  • Device tree (other than /dev/pts)
  • CPU/Kernel/Memory/Swap (obviously)
  • /init binary (but not process)

This is very similar to the way that Docker, Podman, and other container systems work. They may use slightly different configurations for the namespaces, but the core technology is typically the same.

So at a base level, you can reproduce much of what WSL2 does on Ubuntu using containers, be they Docker, Systemd-machined, Podman, or others. There's typically additional configuration needed to run a GUI (especially Desktop environment) in any of these scenarios, but it's also typically possible.

With that in place, you'll be able to check out a distribution's:

  • Package manager
  • Stock repositories
  • Other features like AUR on Arch
  • General configuration (stock shell startup files, etc.)

However, you may have difficulty with networking tools or desktop tools. Also, as with WSL2, the kernel inside the container will be the one from the host Ubuntu distribution, not anything specific to the distribution you are testing.


At a much simpler level than a container, of course, it's even possible to accomplish much of the same experience using a simple chroot environment for a different distribution.

Score:19
hu flag

WSL-2 does use "lightweight utility virtual machine (VM)".

You will always need a VM to run different OS.

There is something better known as Multipass if you just need a shell to test different tools/distros.

Dan M. avatar
cw flag
WSL2 does use vm. WSL1 does not.
Utkarsh Chandra Srivastava avatar
hu flag
@DanM. Yep because WSL1 did not have proper linux kernel behind it was just an compatibility layer for running Linux binary executables.
us flag
I guess it depends what you call an OS, but technically you need a VM to run a different _kernel_. Everything else can run in a container without virtualization. Does it count as running a different OS when you run Alpine in docker on Ubuntu?
NotTheDr01ds avatar
vn flag
@UtkarshChandraSrivastava Congrats on the [Mortarboard](https://askubuntu.com/help/badges/41/mortarboard?userid=1198244)!
phuclv avatar
sd flag
`WSL2 does use "lightweight utility virtual machine (VM)"` would be correct, but *WSL does use "lightweight utility virtual machine (VM)"* is absolutely not
Utkarsh Chandra Srivastava avatar
hu flag
@phuclv Agreed I have updated my answer.
NotTheDr01ds avatar
vn flag
@UtkarshChandraSrivastava I went to try Multiplass since you recommended it, but from the docs, it *only* handles running Ubuntu distributions. It's *available* for multiple distributions (and macOS and Windows), but the only distributions that you can try out are Ubuntu. Is that correct?
cjs avatar
ae flag
cjs
@DidierL It depends on what you are calling an "OS." When you use Docker on Ubuntu to run a "container" created from an Alpine image you have [an Alpine userland running on your Ubuntu kernel](https://stackoverflow.com/a/56606244/107294).
Score:6
tr flag

schroot

TL,DR: schroot is a good way to run programs from another Ubuntu version, or another Debian-based distribution, .

You can try out many aspects of another distribution with schroot. This is the lightest-weight virtualized environment for running a Linux inside another Linux (it's technically a virtual environment, but much in the same sense of Python's virtual environments, if that tells you anything — it doesn't involve any form of CPU-based or kernel-based virtualization).

chroot is a Unix feature that lets you run a program inside a directory, so that the program only sees that directory and its subdirectories, and not the rest of the system. Linux distributions want certain files in specific places (/etc, /lib, etc.), and chroot lets you tell a program that the “real” /etc is actually /somewhere/etc and so on. For example, you install Debian in /debian, and you run chroot /debian bash and get a bash prompt running in Debian. You get Debian's bash, and every program started from that bash is whatever is in Debian, and apt install somepackage will install the package in that Debian and so on, because what the chrooted programs see as /etc is the real /debian/etc and so on. The kernel (so the hardware drivers), the network configuration and all other aspects of the system that aren't determined by disk files are the ones of the outside world.

A chroot has many limitations. For example, since it doesn't see anything outside its own tree, it doesn't have access to /home, /proc, /dev and other critical parts of the system that you'd really like to share. It doesn't have the same user accounts. Also, chroot can bypass security policies, so only root (the system administrator) is allowed to use it.

Schroot is a program that provides a lot of convenience features around the use of chroot to install another Linux operating system. It takes care (based on its configuration) of making directories like /home and /proc available in the schroot, of sharing user accounts, etc. It's available as an Ubuntu package, so you can just install it with apt install schroot or your favorite package manager. Once you've installed the program, create a configuration file to declare the schroot you want (see examples on the Debian wiki or elsewhere on the web).

The next bit is to install another distribution in the schroot environment. How to do this depends on the distribution. Caution — You need to be somewhat careful there because the schroot shares a lot of things with the host, such as network access. If you start a network server inside the schroot, it'll want exclusive access on the port, conflicting with the same software on the host unless the two are configured to use different ports. There is no unified way to install another distribution like this.

Debian and derivatives have two very convenient features to install another distribution inside a chroot environment: debootstrap, and service suppression. Debootstrap (apt install debootstrap) is a tool to download a starter set of packages from Debian, Ubuntu or (perhaps with a little configuration) other Debian-based distribution, and install those packages under a directory of your choice. Modern Debian versions come with service suppression so that installing packages inside a chroot doesn't automatically start system services (be careful about that if you want to try out ancient releases).

For example, I'm a software developer and I sometimes need to test how my software interoperates with older or newer versions of other software. To test interoperability with software from about 2015, I use a schroot with Ubuntu 16.04:

$ cat /etc/schroot/chroot.d/xenial 
[xenial]
description=Ubuntu 16.04
directory=/chroot/xenial
type=directory
groups=users

I started the installation of that system with debootstrap xenial /chroot/xenial https://archive.ubuntu.com/ubuntu/ . Then I ran

sudo schroot apt install [more packages I needed]
schroot ./interoperability-tests

to run my interoperability tests with the programs from Ubuntu 16.04.

NotTheDr01ds avatar
vn flag
Likely a stupid question - (a) because I'm going from memory, (b) that may be impaired from lack of sleep at the moment, and (c) I know you know your stuff. But, I was thinking you could use a bind mount (IIRC, most of which I learned about through your answer on the topic here or U&L) to give the chroot access to the host `/home`, `/proc`, and `/dev`? Or is that just how Schroot handles it for you?
Gilles 'SO- stop being evil' avatar
tr flag
@NotTheDr01ds Not a stupid question at all! You can indeed use a bind mount. And that's what schroot does. It takes care of knowing what bind mounts are needed (and that's configurable), and of unmounting when the schroot session ends.
Score:4
cn flag

In my opinion, you are looking for GNOME Boxes, which uses the cutting edge virtualization technologies as libvirt, libosinfo and qemu but makes the things easy.

enter image description here

Yes - it provides very limited configuration options, but literally said you can install a new operating systems in a virtual machine with about 5 clicks.

To install GNOME Boxes via apt run the following commands:

sudo apt update
sudo apt install gnome-boxes 

Notes and references:

pa4080 avatar
cn flag
Hello, @Quasímodo. If you read the other answers you will see the current version of WSL uses a virtual machine, so that premise is based on a lack of knowledge. On the other hand, GNOME Boxes requires the same level of hardware and the same amount of knowledge like WSL, so I decide to focus on and give a clue about that part: *...you can try different distros... Is there something like that on Linux?* I really do like the other answers and already up-voted them, but I do not believe the OP will find them (especially all tech details) as much useful while they asking such question.
Score:-2
cn flag

At school we use Docker. It's container based, so no VM's required, and it's even better than WSL2 in that aspect (WSL2 uses hidden VM). It only supports cmd though afaik

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.