Skip to content

Instantly share code, notes, and snippets.

@1eedaegon
Last active July 12, 2023 07:42
Show Gist options
  • Save 1eedaegon/b90214fc7b92b2abcb279bedf6f3c7e7 to your computer and use it in GitHub Desktop.
Save 1eedaegon/b90214fc7b92b2abcb279bedf6f3c7e7 to your computer and use it in GitHub Desktop.
How to enable systemd on wsl2

Systemd

Requirements

  • Windows 11
  • WSL 2

Enable systemd option inside wsl2 instance

  1. Add inside /etc/wsl.conf:
[boot] 
systemd = true 
  1. sudo vi /etc/wsl.conf
[boot]
systemd = true

# [Optional] Check if the file has been correctly created
cat /etc/wsl.conf

Restart wsl2 instance

  1. Terminate distro: wsl -t [Distro]
  2. Restart and connect distro: wsl ~ -d [Distro]
PS C:\Users\1eedaegon> wsl ~ -d rhel8
[lee-rhel@rhel8]~% systemctl status
● rhel8
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Sun 2022-11-27 20:05:06 KST; 4s ago
   CGroup: /
           ├─init.scope
           │ └─1 /sbin/init
           ├─system.slice
           │ ├─systemd-journald.service
           │ │ └─25 /usr/lib/systemd/systemd-journald
           │ └─dbus.service
           │   └─34 /usr/bin/dbus-daemon --system --address=systemd: --nofo>
           └─restricted
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment