Script to enable systemd support on current Ubuntu WSL2 images from the Windows store. Tested on 18.04, 20.04, 20.10 versions of Ubuntu from the Windows Store. I am not responsible for broken installations, fights with your roommates and police ringing your door ;-).
Instructions from the snapcraft forum turned into a script. Thanks to Daniel on the Snapcraft forum!
You need git
to be installed for the commands below to work. Use
sudo apt install git
to do so.
git clone https://github.com/alanmburr/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script/
bash ubuntu-wsl2-systemd-script.sh
# Enter your password and wait until the script has finished
systemctl
If you don't get an error and see a list of units, the script worked.
To disable this script (in any case), just press Win + R and type wsl.exe -u root
and press Enter.
Then, continue the steps in the Uninstalling section
To uninstall open your distro and type:
git clone https://github.com/alanmburr/ubuntu-wsl2-systemd-script.git
cd ubuntu-wsl2-systemd-script
bash uninstall.sh
# Enter your [sudo] password to uninstall.
Hopefully it works. If it don't, leave an issue :)
Have fun using systemd on your Ubuntu WSL2 image.