Skip to content

Instantly share code, notes, and snippets.

@Ragdata
Last active March 3, 2023 18:56
Show Gist options
  • Save Ragdata/d8e74781ff959d7e221a5ee52e867bd1 to your computer and use it in GitHub Desktop.
Save Ragdata/d8e74781ff959d7e221a5ee52e867bd1 to your computer and use it in GitHub Desktop.
Enable systemd on WSL2 (Windows 10 & 11)

Enable systemd on WSL2 (Windows 11)

WSL now includes support for running systemd inside your WSL distros. Here's how to set it up:

Ensure you are running the right version of WSL

To set this up, you need to be running WSL version 0.67.6 or higher. You can check your WSL version by running this command under PowerShell or Command Prompt:

wsl --version

If that command fails, then you are running the in-Windows version of WSL and need to upgrade to the Store version.

This version of WSL is currently available to all users who are registered for the Windows Insiders build for starters, and then after a few weeks to ensure quality it will be made available to all users. To check for updates, run wsl --update. If you are not a Windows Insider and want to use this immediately, you can download the latest release from the WSL Release page.

Set the systemd flag in your WSL distro settings

You will need to edit your wsl.conf file to ensure systemd starts on boot.

Add these lines to the /etc/wsl.conf file of each distro where you want to enable systemd.

(requries sudo privileges eg: sudo pico /etc/wsl.conf):

[boot]
systemd=true

And it's really just that easy!

Final Steps

Once this is done, close any open terminal windows and run wsl.exe --shutdown from PowerShell to restart your WSL instances. When WSL reboots, you should have systemd running! You can check this by using the command in your WSL terminal:

systemctl list-unit-files --type=service

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment