Windows with WSL2 (beta)
Nội dung này hiện chưa có sẵn bằng ngôn ngữ của bạn.
A Windows PC (for example a gaming PC with a big GPU) can join your fleet through WSL2, the Linux VM built into Windows. MZPanel runs inside the Linux distro; it never touches Windows. This path is beta: it works, but WSL was made for development, so the box goes offline whenever Windows sleeps, restarts or stops WSL. MZPanel expects that from a homelab box and sends no offline alerts.
1. Install WSL2 and Ubuntu 24.04
Section titled “1. Install WSL2 and Ubuntu 24.04”In PowerShell as administrator (Windows 11, or Windows 10 22H2):
wsl --install -d Ubuntu-24.04wsl --updatewsl -l -v # Ubuntu-24.04 must show VERSION 2Open Ubuntu 24.04 from the Start menu once and create your Linux user.
2. Enable systemd
Section titled “2. Enable systemd”The agent is a systemd service. Inside Ubuntu:
sudo tee /etc/wsl.conf >/dev/null <<'EOF'[boot]systemd=trueEOFThen in PowerShell: wsl --shutdown, and open Ubuntu again. Check:
ps -p 1 -o comm= # systemdsystemctl is-system-running # running (or degraded: fine)The installer stops with a pointer back here if systemd is not running.
3. Give WSL enough memory
Section titled “3. Give WSL enough memory”By default WSL2 takes up to half of the PC’s RAM and stops the VM when it is idle. Create
%UserProfile%\.wslconfig (for example C:\Users\you\.wslconfig):
[wsl2]memory=8GBprocessors=4swap=4GB# Windows 11 22H2+: share the PC's network, so LAN devices reach the box's appsnetworkingMode=mirroredRun wsl --shutdown after every change. networkingMode=mirrored is only needed for LAN-only
URLs; the Cloudflare Tunnel works without it (it dials out).
4. Start WSL at logon and keep it running
Section titled “4. Start WSL at logon and keep it running”WSL stops the distro a few seconds after the last Linux process outside systemd exits. A scheduled task that starts at logon and keeps one process alive solves both. In PowerShell (as your normal user, not administrator):
$action = New-ScheduledTaskAction -Execute "wsl.exe" -Argument "-d Ubuntu-24.04 --exec /bin/sh -c 'exec sleep infinity'"$trigger = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit ([TimeSpan]::Zero) -HiddenRegister-ScheduledTask -TaskName "WSL keepalive (MZPanel)" -Action $action -Trigger $trigger -Settings $settingsThe task runs when you sign in. After a Windows restart the box comes back once someone signs in, so enable automatic sign-in if the PC must recover on its own (Windows settings > Accounts > Sign-in options, or Sysinternals Autologon).
5. Keep the PC awake
Section titled “5. Keep the PC awake”In PowerShell as administrator:
powercfg /change standby-timeout-ac 0powercfg /change hibernate-timeout-ac 0powercfg /change monitor-timeout-ac 15On a laptop also set Lid close action: Do nothing (on AC power) and keep it plugged in. Set Windows Update > Active hours so updates do not restart it at a bad time.
6. Install the agent inside Ubuntu
Section titled “6. Install the agent inside Ubuntu”Use the command from Servers > Add server and add MZ_PROFILE=homelab:
curl -fsSL https://get.mzpanel.com | sudo INSTALL_TOKEN=<install-token> MZ_PROFILE=homelab bashThe homelab profile installs Docker Engine inside the distro. Do not use Docker Desktop’s WSL integration for the same distro at the same time: two engines on one distro conflict.
WSL2 uses the Windows NVIDIA driver: install the normal Windows driver (no Linux driver in the
distro), then the NVIDIA Container Toolkit inside Ubuntu. nvidia-smi must work inside the
distro before containers can use the GPU.
Troubleshooting
Section titled “Troubleshooting”| Symptom | Fix |
|---|---|
| Installer: “systemd is not running in this WSL distro” | step 2, then wsl --shutdown |
| Installer: “This machine looks like a personal computer” | add MZ_PROFILE=homelab |
| Box offline after you close the terminal | the keepalive task (step 4) is missing or disabled |
| TLS or token errors after the PC slept | the distro clock drifted: sudo hwclock -s, or restart WSL |
LAN devices cannot open http://<app>.home.arpa | networkingMode=mirrored (step 3), and allow the port in Windows Defender Firewall |