• Stars
    star
    1,905
  • Rank 24,350 (Top 0.5 %)
  • Language
    Rust
  • License
    MIT License
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Distrod is a meta-distro for WSL 2 which installs Ubuntu, Arch, Debian, Gentoo, etc. with systemd in a minute for you. Distrod also has built-in auto-start feature on Windows startup and port forwarding ability.

Distrod - WSL2 Distros with Systemd!

CI

Distrod is a systemd-based meta-distro for WSL2 that allows you to install Ubuntu, Arch Linux, Gentoo and many other distros with systemd in a minute, or make your current distro run systemd.

Distrod also provides built-in auto-start feature and port forwarding service. This allows you to start systemd-managed services, such as ssh, on Windows startup and make it accessible from outside Windows.

Arch, Debian, and Gentoo are running on WSL 2 with systemd running Demo gif

With Distrod, you can

  1. Run systemd in WSL 2
    You can do the both of the following

    • Install a new distro with systemd running
    • Make your current WSL 2 distro run systemd
  2. Install any image available from linuxcontainers.org as a WSL 2 distro in 1 minute1.

    • The following distros are continuously tested
      • Ubuntu, Debian, Arch Linux, Fedora, CentOS, AlmaLinux, Rocky Linux, Kali Linux, Linux Mint, openSUSE, Amazon Linux, Oracle Linux, Gentoo Linux
        CI (See Integration test on Linux (distro_name))
    • Other distros may or may not work

    * linuxcontainers.org is a vendor-neutral project that offers distro images for containers, which is unrelated to Distrod. LXC/LXD is one of its projects. Systemd runs in the installed distro, so you can also try LXC/LXD in WSL!

  3. Start WSL on Windows Startup.
    This means that you can manage your ssh server and other services with systemd and start them automatically without any hassle!

    • Distrod also provides a port proxy service managed by systemd, allowing you to expose your Linux server to the outside world of Windows easily.

Feature under development

  1. Make your dual-booted physical Linux distro on a separate disk run as a WSL instance.

Install

Option 1: Install a New Distro.

  1. Make sure that your default WSL version is 2.

    > wsl --set-default-version 2
  2. Download and unzip the latest distrod_wsl_launcher-x86_64.zip from release, and double-click the extracted .exe file.

  3. Follow the wizard to install a new distro.

  4. [Optional] To make your distro start on Windows startup, run the following command.

    sudo /opt/distrod/bin/distrod enable --start-on-windows-boot

    You also might want to forward ports of services such as ssh to the outside of Windows. In that case, you can enable the built-in port proxy service provided by Distrod.

    NOTE: On Windows 11, portproxy.service doesn't work on Windows startup, which should be fixed soon. See Known bus.

    echo 22 | sudo tee /opt/distrod/conf/tcp4_ports  # update the portproxy.service's configuration
    sudo systemctl enable --now portproxy.service  # enable and start it

    For more detailed instruction, see Forward Ports to outside of Windows.

See also

Option 2: Make your Current Distro Run Systemd

By this installation, systemd is enabled in your WSL 2 distro.

  1. Download and run the latest installer script.

    curl -L -O "https://raw.githubusercontent.com/nullpo-head/wsl-distrod/main/install.sh"
    chmod +x install.sh
    sudo ./install.sh install

    This script installs distrod, but doesn't enable it yet.

  2. Enable distrod in your distro

    You have two options. If you want to automatically start your distro on Windows startup, enable distrod by the following command

    /opt/distrod/bin/distrod enable --start-on-windows-boot

    Otherwise,

    /opt/distrod/bin/distrod enable

    You can run enable with --start-on-windows-boot again if you want to enable autostart later.

  3. Restart your distro

    Close your WSL's terminal. Open a new Command Prompt window, and run the following command.

    wsl --terminate Distrod

    After re-opening a new WSL window, your shell runs in a systemd session.

See also

Usage

If you are using Windows Terminal, Windows Terminal will automatically find and register Distrod for you. Just open the tab named "Distrod".

If you are using other terminals, please update your terminal settings to launch the Distrod. For reference, the following command launches a distro by name in WSL

> wsl --distribution Distrod

Update Distrod

  1. Inside a Distrod session, download and run the latest installer script.

    curl -L -O "https://raw.githubusercontent.com/nullpo-head/wsl-distrod/main/install.sh"
    chmod +x install.sh
    sudo ./install.sh update

How Distrod Works

In a nutshell, Distrod is a binary that creates a simple container that runs systemd as an init process, and starts your WSL sessions within that container. To realize that, Distrod does the following things.

  • Modify the rootfs of the concrete distro you chose so that it is compatible with both WSL and systemd.
    • Modify systemd services so that they are compatible with WSL
    • Configure networks for WSL
    • Put /opt/distrod/bin/distrod and other resources in the rootfs.
    • Register the Distrod's binary as the login shell
  • When Distrod is launched by WSL's init as a login shell, Distrod
    1. Starts systemd in a simple container
    2. Launches your actual shell within that container
    3. Bridges between the systemd sessions and the WSL interop environment.

Other Notes

  1. Does WSLg works on Distrod?

    Yes! Distrod doesn't prevent anything about WSLg. Distrod sets up sockets for X11 and environment variables properly.

    However, WSLg itself has some quirks even on non-Distrod WSL2 distros. Try many things until a GUI app runs. For example, to run xeyes without failure, I had to run it three times on the non-Distrod official Ubuntu 20.04.

See also

Footnotes

  1. as long as your network connection is fast enough :) ↩

More Repositories

1

WSL-Hello-sudo

Let's sudo by face recognition of Windows Hello on Windows Subsystem for Linux (WSL). It runs on both WSL 1 and WSL 2. This is a PAM module for Linux on WSL.
Rust
1,210
star
2

dbgee

The zero-configuration debuggee for debuggers. Handy utility that allows you to launch CLI debuggers and VSCode debuggers from the debuggee side.
Rust
88
star
3

Out-of-the-Box-CodeServer

OOTB Code-Server is an out-of-the-box Code-Server environment. It provides Https proxy, GItHub authorization and automatic shutdown with just a few settings.
Shell
86
star
4

xv6-mips

A MIPS port of xv6
C
69
star
5

Windows-10-Virtual-Desktop-Switching-Shortcut

A tool to make up for the lack of "Switch to Nth Virtual Desktop" shortcut in windows 10
C++
24
star
6

source-win-bat

A utility to run Windows Batch files in WSL / Cygwin / MSYS2 and sync the environment variables, doskeys, and working directories.
Ruby
14
star
7

x86-MSR-header

A Public-domain C header file for x86 MSR (Model Specific Register) addresses, and a naive generator of it.
C
13
star
8

Rusty-L4

Rust
6
star
9

winsomnia-ssh

Prevents Windows from sleeping during ssh in WSL. It also provides a handy CLI, `winsomnia`, which allows you to pause sleep whenever you want, for however long you want.
Python
5
star
10

seccamp-17-Y-track-RS232C

Verilog
5
star
11

FPGA-Brainfuck-Processor

A brainfu*k processor written in VHDL.
VHDL
3
star
12

ELVM-Interpreter-in-Rust

An ELVM interpreter in Rust
Rust
2
star
13

Tiny-Ruby-DSL-Assembler-Generator-

A tiny assember generator created as Ruby DSL.
Ruby
2
star
14

Wrench-ChatApplicationDemo

A demonstration of websocket php chat application with wrench
PHP
1
star
15

fueledbycoffee

HTML
1
star
16

yesod-init-result

An yesod init result in my environment for sakas
Haskell
1
star
17

add--create-a-symbolic-link--to-the-context-menu

Add "create a symblic link" to the context menu in windows7.
C++
1
star