Skip to content

Script to enable systemd support on current Ubuntu WSL2 images [Unsupported, no longer updated]

Notifications You must be signed in to change notification settings

MagicStar7213/ubuntu-wsl2-systemd

 
 

Repository files navigation

ubuntu-wsl2-systemd

This is a fork of DamionGans ubuntu-wsl2-systemd-script for Ubuntu 22.04 WSL2 as it does not work in this version with the original repo. Hope it helps. Updates made from Issue #36 of ubuntu-wsl2-systemd-script

There will not be updates as Microsoft added systemd support in latest WSL. This was only an update so you could enable systemd in older Ubuntu 22.04 WSL2

Instructions from the snapcraft forum turned into a script. Thanks to Daniel on the Snapcraft forum!

Enabling systemd

First, update WSL. Run in cmd or PowerShell as admin

wsl --update

Then, start your favourite distro and create or edit wsl.conf in /etc :

sudo nano /etc/wsl.conf

In it, write:

[boot]
systemd=true

After, run

wsl --shutdown

And start again your distro. And you're done! Enjoy systemd for installing snaps or whatever you want to do with it.

Usage

You need git to be installed for the commands below to work. Use

sudo apt install git

to do so.

Run the script and commands

git clone https://github.com/MagicStar7213/ubuntu-wsl2-systemd.git
cd ubuntu-wsl2-systemd/
bash ubuntu-wsl2-systemd-script.sh
# Enter your password and wait until the script has finished

Then restart the Ubuntu shell and try running systemctl

systemctl

If you don't get an error and see a list of units, the script worked.

Have fun using systemd on your Ubuntu WSL2 image. You may use and change and distribute this script in whatever way you'd like.

About

Script to enable systemd support on current Ubuntu WSL2 images [Unsupported, no longer updated]

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%