All Projects → diddledani → one-script-wsl2-systemd

diddledani / one-script-wsl2-systemd

Licence: MIT license
The one-script variant of the systemd hack for WSL2

Programming Languages

powershell
5483 projects
shell
77523 projects

Projects that are alternatives of or similar to one-script-wsl2-systemd

subsystemctl
Utility to run systemd in WSL2 with a Linux namespace
Stars: ✭ 313 (+59.69%)
Mutual labels:  systemd, wsl2
wsl-systemd
A script that spawns a namespace with systemd as PID1, and allows you to spawn interactive sessions or exec commands inside it
Stars: ✭ 37 (-81.12%)
Mutual labels:  systemd, wsl2
WSL2setup
Install WSL2 and handle dependencies
Stars: ✭ 55 (-71.94%)
Mutual labels:  wsl2
go-systemd-time
📅 Go implementation of systemd relative time adjustments
Stars: ✭ 21 (-89.29%)
Mutual labels:  systemd
dotfiles
🏡 Personal dotfiles configuration
Stars: ✭ 73 (-62.76%)
Mutual labels:  systemd
cya
Easy to use snapshot and restore utility for any Linux (Unix) OS and filesystem powered by BASH
Stars: ✭ 73 (-62.76%)
Mutual labels:  systemd
systemd-formula
No description or website provided.
Stars: ✭ 24 (-87.76%)
Mutual labels:  systemd
parca-agent
eBPF based always-on profiler auto-discovering targets in Kubernetes and systemd, zero code changes or restarts needed!
Stars: ✭ 250 (+27.55%)
Mutual labels:  systemd
gentoo-project-gnome-without-systemd
GNOME Without Systemd
Stars: ✭ 89 (-54.59%)
Mutual labels:  systemd
dotfiles
Cross platform home directory settings
Stars: ✭ 17 (-91.33%)
Mutual labels:  wsl2
usbipd-win
Windows software for sharing locally connected USB devices to other machines, including Hyper-V guests and WSL 2.
Stars: ✭ 1,321 (+573.98%)
Mutual labels:  wsl2
sysdweb
Control systemd services through Web or REST API
Stars: ✭ 65 (-66.84%)
Mutual labels:  systemd
node-systemd-journald
Native bindings to journald
Stars: ✭ 26 (-86.73%)
Mutual labels:  systemd
deploy
No description or website provided.
Stars: ✭ 23 (-88.27%)
Mutual labels:  systemd
service-systemd
Setup a node.js app as systemd service.
Stars: ✭ 35 (-82.14%)
Mutual labels:  systemd
InitKit
Neo-InitWare is a modular, cross-platform reimplementation of the systemd init system. It is experimental.
Stars: ✭ 364 (+85.71%)
Mutual labels:  systemd
stonehenge
Multi-project local development environment & toolset on Docker
Stars: ✭ 47 (-76.02%)
Mutual labels:  wsl2
erlang-systemd
systemd utilities for Erlang applications
Stars: ✭ 140 (-28.57%)
Mutual labels:  systemd
fuck systemd
A library to bring the joys of non-systemd users to systemd users
Stars: ✭ 19 (-90.31%)
Mutual labels:  systemd
sysz
An fzf terminal UI for systemctl
Stars: ✭ 1,258 (+541.84%)
Mutual labels:  systemd

About

This repository includes the files to set-up WSL2 distro to run systemd.

What does it do

In WSL2

  • Install a script that starts systemd inside a process namespace so that it gets PID 1.
  • Install a sudoers configuration file that allows the script to call itself as root without requring setuid.
  • Install GPG and SSH agent relays to Windows equivalents.
  • Install WSLUtilities
  • Configure your WSL sessions to connect to an X11 server in Windows, or use WSLg if it is available on your system.
  • Configure xdg-open to open files and addresses in Windows

In Windows

  • Install GPG4Win via winget.exe, which is available in the latest dev branch of Windows 10 Insider Preview. (disable this with -NoGPG)
  • Add a scheduled task that launches when you login to Windows to start the GPG-Agent from GPG4Win
  • Install a custom WSL kernel based on the Microsoft sources with AppArmor added to support Snap Package strict confinement. (disable this with -NoKernel)
  • Add a scheduled task that launches when you login to Windows to update the custom kernel when a new release is made.
  • Enable and start the in-built Windows SSH-Agent service.

Installing

  1. Run Install-Module -Scope CurrentUser Wsl to install the required PowerShell module
  2. Download the install.ps1 script
  3. Open a PowerShell or CMD window: press Win + x then choose either "Command Prompt" or "Windows PowerShell" depending on which your system presents in the menu
  4. Run the following command in the PowerShell Core or CMD window to set up your default distro (make sure to replace powershell.exe with pwsh.exe if you're using PowerShell Core):
    pwsh.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -File \path\to\install.ps1

If you want to skip the GPG4Win installation, use the flag -NoGPG

You can also specify a distro name with the -distro flag, e.g:

pwsh.exe -NonInteractive -NoProfile -ExecutionPolicy Bypass -File \path\to\install.ps1 -distro Ubuntu-20.04

You will find all the available distros on your system when executing wsl.exe --list --all in command prompt

Currently supported distros:

  • Ubuntu
  • Kali Linux
  • Debian
  • Alpine
  • OpenSUSE
  • Any other linux distribution with apt-get or zypper as package manager

Minimal manual installation

To manually install the bare-minimum setup, i.e. without using the PowerShell script, follow the procedure below:

  1. Edit or create the config file at /etc/wsl.conf to add the following content:
    [boot]
    command = "/usr/bin/env -i /usr/bin/unshare --fork --mount-proc --pid -- sh -c 'mount -t binfmt_misc binfmt_misc /proc/sys/fs/binfmt_misc; [ -x /usr/lib/systemd/systemd ] && exec /usr/lib/systemd/systemd --unit=multi-user.target || exec /lib/systemd/systemd --unit=multi-user.target'"
  2. Copy src/sudoers to /etc/sudoers.d/wsl2-systemd.
  3. Copy src/00-wsl2-systemd.sh to /etc/profile.d/00-wsl2-systemd.sh.
  4. Ensure that your user account is a member of the sudo group, or change %sudo in /etc/sudoers.d/wsl2-systemd to an alternative group name of which your account is a member.
  5. Exit any active terminal sessions that are using your distro.
  6. Use wsl.exe via powershell to terminate/shutdown your distro so that the wsl.conf settings are applied.
    wsl.exe --terminate ubuntu

Alternatives

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].