Skip to content

The-Monkey-King/wsl2-systemd-alwayson-script

 
 

Repository files navigation

wsl2-systemd-alwayson-script

This script allows Linux distributions to run unabated in a Windows user session without an active Terminal. This is especially useful for running Klipper from a Windows OS.

Tested On

  • Windows 10 (22H2 - 19045)

  • Windows Terminal 1.17.11461.0

  • Windows Subsystem for Linux (WSL) 2

  • Debian (Bookworm)

  • KIAUH*: Klipper (v0.11.0)

  • KIAUH: Moonraker (v0.8.0)

  • KIAUH: Mainsail (v2.6.2)

    *Installed through Klipper Installation And Update Helper (KIAUH)

Installation Instructions

This process is intended to be peformed after installing Klipper, Moonraker, and Mainsail. However, Mookraker may need to be updated after this process. (See "Policykit Update" below)

Remember, to use Klipper in WSL2, you must enable systemd by adding the /etc/wsl.conf file to your Linux distribution with the following system declaration:

[boot]
systemd=true

Open Terminal and Linux Instance Tabs

This example Linux distribution does not need an Administration level account. Just right-click on the Windows CMD icon and select Terminal. Once the application opens, click on the downward caret and select your Linux instance. You will need both tabs open for the next set of instructions.

Terminal shell

Linux Tab: Run this script and these commands

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

Terminal Tab: Run these commands

setx WSLENV BASH_ENV/u
setx BASH_ENV /etc/bash.bashrc

Restart and Test

  1. Close the Linux tab
  2. In the Terminal tab, run the command:
wslconfig /t <Linux_instance>
  1. Restart Linux by opening it in a new tab
  2. In the Linux tab, run the command:
    systemctl

If you see a list of units and no errors, the script worked. You can test this further by opening a web browser to your Mainsail page (usually localhost / 127.0.0.1). Close the Terminal application. Klipper should still work as expected.

Moonraker warning: Unable to find Dbus Polkit interface

If you encounter this error in the Mainsail web interface, after restarting the Linux instance, you will need to set Moonraker's PolicyKit Rules for granting access

In the Linux tab, run the command:

~/moonraker/scripts/set-policykit-rules.sh

Restart the Linux instance.

Notices

This script is Open Source and free to implement under GNU General Public License v3.0. I am not responsible for broken installations, tears, or loss of social status when using this script.

About

Script to enable always on Debian WSL2 instances [Modified from DamionGans script]

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%