Home Technology News Tech How to enable systemd in Windows Subsystem for Linux (WSL)

How to enable systemd in Windows Subsystem for Linux (WSL)

0
How to enable systemd in Windows Subsystem for Linux (WSL)

Whether systemd in Linux is good or bad will depend on who you talk to, but it is important, so much so that some of the Windows Subsystem for Linux (WSL) community had been building their own ways to implement it. Microsoft has done the work now, though, in partnership with Canonical, to officially implement systemd in WSL.

Initially, though, it isn’t actually just available to everyone and enabled by default. You also have the ability to disable it at any time once you’ve enabled it. Here’s what you need to know.

What is systemd?

The short, official description of systemd is:

Systemd is a suite of basic building blocks for a Linux system. It provides a system and service manager that runs as PID 1 and starts the rest of the system.

Some of the most popular Linux distros out there already use systemd by default on bare metal installs. Some of these, such as Ubuntu and Debian, are also available on WSL.

The inclusion of systemd on WSL brings the tool even closer to the experience of natively running Linux. It’s also required for some tools which are now easily useable on WSL, such as snap, microk8s, and systemctl.

What you need to get systemd in WSL

systemd on WSL

If you’re using the in-Windows version of WSL, that is, the one you enabled through PowerShell and not downloaded from the Store, you won’t have systemd initially. Only those using an Insider build of Windows 11, or those using WSL as downloaded from the Microsoft Store will have it. The version number you need is 0.67.6 and above.

To check if you have the right version, simply open up a PowerShell window and enter wsl –version and check the response. If it’s below 0.67.6, head to the Microsoft Store and download WSL. Alternatively, you can grab the latest release from the WSL GitHub repo.

In the future, all users will get systemd support added, and you can check for any updates to WSL by entering wsl –update in PowerShell.

Alternatively, if you’re using Ubuntu Preview on WSL, systemd is being added automatically.

How to enable systemd

systemd on WSL

To enable systemd, at least right now, you will have to add an instruction to your wsl.conf file. This is a configuration file found within any WSL Linux distro and allows you to configure on a per-distro basis, rather than amending global WSL settings.

It’s a simple text file, so you just need to open it up in a text editor. In this example, we’re using Nano. Open up your wsl.conf in your chosen Linux distro by entering the following:

sudo nano /etc/wsl.conf

You’ll now most likely be looking at a blank document unless you’ve previously built your own config file.

systemd on WSL

To enable systemd simply enter this into your wsl.conf file:

[boot]
systemd=true

Now you can simply save and exit the file (CTRL+O to save and CTRL+X to exit). From here you need to close shutdown your WSL session entirely. Close out of Linux and go back to a PowerShell window and enter:

wsl.exe --shutdown

This will completely shut down WSL on your machine. Now simply re-open your Linux distro. The first boot may take a few seconds longer, but when it’s up you’ll have systemd running. You can check it’s working using systemctl, one of the services that rely on systemd:

systemctl list-unit-files --type=service

You should see a list of the running services now. That’s all there is to enabling systemd. And of course, by changing to false in your wsl.conf you can turn it off if you wish at any time.

Using snap on Ubuntu on WSL

Snap on WSL

One of the added bonuses to using systemd on Ubuntu on WSL is that snap now works properly. Not everyone will be running to use it, but it’s another feature WSL users have access to. And there are some useful snap packages you might want to try.

Nextcloud, for example, is an open-source alternative to Microsoft 365 and Google’s cloud apps and storage. The Nextcloud snap is one of the best ways to install it on Linux and that’s now open on WSL. Installing snaps is the same as using apt (or any other package manager) substituting snap in place:

sudo snap install nextcloud

You can quickly find available snaps by checking out snapcraft.io.

LEAVE A REPLY

Please enter your comment!
Please enter your name here