Skip to content

Instantly share code, notes, and snippets.

@annasoldih
Last active October 18, 2022 09:51
Show Gist options
  • Save annasoldih/05a3423c877eae701076436cf00bbd43 to your computer and use it in GitHub Desktop.
Save annasoldih/05a3423c877eae701076436cf00bbd43 to your computer and use it in GitHub Desktop.
Enable SYSTEMD on WSL2

Enable SYSTEMD on WSL2

This few steps will enable SYSTEMD on your WSL2. By enabling SYSTEMD you will be able to run snaps, docker, heroku and many more features.

This guide was made and tested on Windows 11, using Ubuntu 20.04 LTS in WSL2.

Requirements

  • Windows 11 (it should also work on Windows 10)
  • WSL2
  • SYSTEMD-GENIE

Installation

  • Copy the install-sg.sh file:
cd /tmp
wget --content-disposition \
  "https://gist.github.com/annasoldih/05a3423c877eae701076436cf00bbd43#file-install-sg-sh"
  • Make the install-sg.sh file executable:

    chmod +x /tmp/install-sg.sh
  • Run the executable file:

    /tmp/install-sg.sh && rm /tmp/install-sg.sh
  • Restart your computer

  • You can check if it is already working on your WSL terminal:

    sudo systemctl status time-sync.target
  • If it is not working, you can enable it on your powershell terminal:

    wsl genie -s
  • Test it again on your WSL terminal:

    sudo systemctl status time-sync.target

Habilite o SYSTEMD no WSL2

Esses passos lhe guiarão a habilitar o SYSTEMD no seu WSL2. Habilitando o SYSTEMD você poderá executar snaps, docker, heroku e muitos outros.

Esse guia foi feito e testado no Windows 11, usando Ubuntu 20.04 LTS no WSL2.

Requerimentos

  • Windows 11 (também deve funcionar no Windows 10)
  • WSL2
  • SYSTEMD-GENIE

Instalação

  • Copie o arquivo install-sg.sh:
cd /tmp
wget --content-disposition \
  "https://gist.github.com/annasoldih/05a3423c877eae701076436cf00bbd43#file-install-sg-sh"
  • Torne o arquivo install-sg.sh executável:

    chmod +x /tmp/install-sg.sh
  • Execute o arquivo:

    /tmp/install-sg.sh && rm /tmp/install-sg.sh
  • Reinicie seu computador

  • Você pode checar se está funcionando no seu terminal WSL:

    sudo systemctl status time-sync.target
  • Se não estiver funcionando, habilite no seu terminal powershell:

    wsl genie -s
  • Teste novamente no seu terminal WSL:

    sudo systemctl status time-sync.target
#! /usr/bin/env bash
set -e
UBUNTU_VERSION="20.04"
GENIE_VERSION="1.44"
GENIE_FILE="systemd-genie_${GENIE_VERSION}_amd64"
GENIE_FILE_PATH="/tmp/${GENIE_FILE}.deb"
GENIE_DIR_PATH="/tmp/${GENIE_FILE}"
function installDebPackage() {
sudo dpkg -i "${GENIE_FILE_PATH}"
rm -rf "${GENIE_FILE_PATH}"
}
function downloadDebPackage() {
rm -f "${GENIE_FILE_PATH}"
pushd /tmp
wget --content-disposition \
"https://github.com/arkane-systems/genie/releases/download/v${GENIE_VERSION}/systemd-genie_${GENIE_VERSION}_amd64.deb"
popd
}
function installDependencies() {
sudo apt-get update
wget --content-disposition \
"https://packages.microsoft.com/config/ubuntu/${UBUNTU_VERSION}/packages-microsoft-prod.deb"
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 \
systemd-container
sudo rm -f /usr/sbin/daemonize
sudo ln -s /usr/bin/daemonize /usr/sbin/daemonize
}
function main() {
installDependencies
downloadDebPackage
installDebPackage
}
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment