Skip to content

Instantly share code, notes, and snippets.

Forked from djfdyuruiry/
Created October 7, 2022 04:32
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
WSL 2 - Enabling systemd

Enable systemd in WSL 2

NOTE: There is now an official way to do this in WSL 2, use it if possible - see MS post here

This guide will enable systemd to run as normal under WSL 2. This will enable services like microk8s, docker and many more to just work during a WSL session. Note: this was tested on Windows 10 Build 2004, running Ubuntu 20.04 LTS in WSL 2.

  • To enable systemd under WSL we require a tool called systemd-genie

  • Copy the contents of to a new file /tmp/

    cd /tmp
    wget --content-disposition \
  • Make it executable:

    chmod +x /tmp/
  • Run the new script:

    /tmp/ && rm /tmp/
  • Exit the WSL terminal and shutdown the WSL env:

    wsl --shutdown
  • To open a new WSL terminal with systemd enabled, run:

    wsl genie -s
  • Prove that it works:

    sudo systemctl status
#! /usr/bin/env bash
set -e
# change these if you want
function installDebPackage() {
# install repackaged systemd-genie
sudo dpkg -i "${GENIE_FILE_PATH}"
rm -rf "${GENIE_FILE_PATH}"
function downloadDebPackage() {
rm -f "${GENIE_FILE_PATH}"
pushd /tmp
wget --content-disposition \
function installDependencies() {
sudo apt-get update
wget --content-disposition \
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install -y \
daemonize \
dotnet-runtime-5.0 \
sudo rm -f /usr/sbin/daemonize
sudo ln -s /usr/bin/daemonize /usr/sbin/daemonize
function main() {
Copy link

When I ran the script it didn't look like it worked (but it did).

Timed out waiting for systemd to enter running state.
This may indicate a systemd configuration error.
Attempting to continue.
Failed units will now be displayed (systemctl list-units --failed):
  UNIT                       LOAD   ACTIVE SUB    DESCRIPTION    >
● systemd-remount-fs.service loaded failed failed Remount Root an>
● multipathd.socket          loaded failed failed multipathd cont>```

The test command worked though:

```sudo systemctl sta
[sudo] password for bruce:
● - System Time Synchronized
     Loaded: loaded (/lib/systemd/system/; static>
     Active: active since Thu 2022-10-06 23:34:35 CDT; 6min ago
       Docs: man:systemd.special(7)```

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