Hello,
I wanted to ask whether there are ideas to support dietpi as a wsl distro. ![]()
Hello,
I wanted to ask whether there are ideas to support dietpi as a wsl distro. ![]()
My last information is, that WSL don’t support systemd, which is a basic requirement for DietPi. Not sure if this changed in meantime.
Thanks for the quick answer!
It seems like systemd is available since last september:
I dont want to push any things which are not in the diepi’s creators mind, just asking because I tried pengwin wsl distro and it was way more limited than what I am used to with dietpi ![]()
Theoretically WLS2 is working using Debian and our own install script Supported hardware - DietPi.com Docs
Additional settings might be needed inside WLS Debian to fix some DNS issues and to force systemd
root@gram:~# cat /etc/wsl.conf
[network]
generateResolvConf = false
[boot]
systemd=true
root@gram:~#
I changed WSL Debian as default in Windows cmd
C:\>wsl --list --all
Windows Subsystem für Linux-Distributionen:
Debian (Standard)
Ubuntu
C:\>
and use wsl -u root to start conatiner as user root. At least from same host system, SSH is working as well
However I had some network issues and it was needed to set STATIC IP. Somehow DHCP was not working as it did not set a default gateway. Not sure why becuase it worked on first place. ![]()
I made a quick test with a VM under Proxmox. But I could not activate the Hyper-V hypervisor in the machine, so in this environment, i failed to install WSL 2 to run the DietPi conversion script.
@andey what would be your use case for running DietPi WSL system?
I do not have a specific use case to be honest.
My simple idea was, that it might be a good thing to be able to test changes before applying them to my productive dietpi system.
Perhaps it would even be possible to make a backup of a dietpi system and troubleshoot it using wsl.
Or simply using the quick installer to spin up a webserver/dev-environment/… for development or testing new software and so on ![]()
For testing, it might be easiest to use Hyper-V or VirtualBox. There you could use fully supported VM’s
However, your idea of restoring systems on a VM might not goanna work. You need to keep in mind the chip architecture used. Usually, SBC are based an ARM while VM’s or native PC use x86. Therefore, you can’t restore such a backup. It depends on what your source system is and where you like to restore on. Even between SBC this will not work. Each manufacture use own kernel and software modules. In an ideal world you would have 2 identical systems that you can compare with each other ![]()
I was just brainstorming ![]()
Since I do not want to a WSL2 Debian image or Docker container as a starting point for a DietPi WSL2 image, I’m still trying to future out how to create one from scratch, via debootstrap only. It does not need a bootloader and no kernel, so is close to a container image (well, of course, a Docker image can be imported). It internally mounts an /init “file” as primary or secondary (if systemd support is enabled) init command, similar to how it exists in Docker images. But something else is missing for WSL2 to boot an image. If anyone knows what this might be, I’d be highly interested.
I’ll have another careful look into the VHDX image file of minimised official WSL2 Debian image to hopefully find other required files/dirs needed for WSL to boot it.
Hi there,
with windows 11 there is support for bridged mode, but still undocumented. I’ve managed to assign static ip as per Bridged Networking under WSL - by Alistair Young article. Unfortunately pi hole uses lighttpd as service, and I want to use nginx, and couldn’t manage to setup correctly. nginx also changed some config file and folder structure, there is no sites-enabled for example.
For setting ip at boot I’ve used crontab “@reboot /usr/local/bin/configure_ip.sh” it contains just ip addr add dev eth0 … and add route stuff
If there is no web server installed at the beginning, you should be ask which web server to choose. We offer installation for Nginx and Apache as well.
I figured out how make DietPi work in WSL2. You first download the Native PC x86_64 hard drive image, not the installer, and flash it to a usb pendrive. Once that has booted onto a computer, run the command “tar -cvpf /dietpi.tar --exclude=/dietpi.tar --exclude=sys --exclude=dev --exclude=proc /” and it will put a copy of almost the entire system into a .tar archive. Be sure that the archive is accessible from within Windows. Next, boot into Windows, open PowerShell, and type in the command “wsl.exe --import DietPi C:<whatever folder you want to put your WSL2 system folder into>\Dietpi \dietpi.tar” and wait for it to finish. After that finishes, it will be ready to use.
If you want to enable systemd support, create a file in /etc called ‘wsl.conf’ that will contain the settings for this WSL2 distro. On a distro installed from the Microsoft Store or PowerShell, this would already exist. In the file, write “[boot]” into the first line, then “systemd=true” into a second line. After you save that file, end the running session of WSL and wait about eight seconds, or until ‘wsl.exe --list --running’ shows that your DietPi distro isn’t running. Then you can boot up DietPi in WSL2 again and the changes made to ‘wsl.conf’ will be in effect.
There are more settings you can put in that WSL config file. They can be found at Advanced settings configuration in WSL | Microsoft Learn
2025 Update:
I attempted to run the DietPi install script on a fresh instance of Debian in WSL, but I terminated the process because I didn’t like what I saw.
“Removing misc files/folders/services, not required by DietPi” … Looks like it was trying to delete everything on my C drive.
[ INFO ] DietPi-Installer | Removing misc files/folders/services, not required by DietPi
[ OK ] DietPi-Installer | rm -Rf /var/lib/dhcp/* /var/lib/dhcp/.??* /var/lib/dhcp/.[^.]*
[ OK ] DietPi-Installer | rm -f /var/lib/misc/*.leases
[ OK ] DietPi-Installer | rm -Rf /var/backups/* /var/backups/.??* /var/backups/.[^.]*
[ OK ] DietPi-Installer | rm -f /etc/*.org
[ OK ] DietPi-Installer | rm -Rf /usr/src/* /usr/src/.??* /usr/src/.[^.]*
find: ‘/mnt/c/$RECYCLE.BIN/S-1-5-18’: Permission denied
find: ‘/mnt/c/$RECYCLE.BIN/S-1-5-21-1796331958-3498830284-3637106410-1001’: Permission denied
find: ‘/mnt/c/Config.Msi’: Permission denied
find: ‘/mnt/c/OneDriveTemp/S-1-5-21-1796331958-3498830284-3637106410-1001’: Permission denied
find: ‘/mnt/c/Program Files/Microsoft SQL Server/MSSQL15.SQLEXPRESS/MSSQL/DATA’: Permission denied
find: ‘/mnt/c/Program Files/Microsoft SQL Server/MSSQL15.SQLEXPRESS/MSSQL/JOBS’: Permission denied
find: ‘/mnt/c/Program Files/Microsoft SQL Server/MSSQL15.SQLEXPRESS/MSSQL/Log’: Permission denied
find: ‘/mnt/c/Program Files/Windows Defender Advanced Threat Protection/Classification/Configuration’: Permission denied
find: ‘/mnt/c/Program Files/WindowsApps’: Permission denied
find: ‘/mnt/c/ProgramData/Intel/IntelSGXPSW’: Permission denied
It is searching for some file pattern, but you should probably unmount that C drive to be sure.
Yea, WSL automounts you windows partitions by default.
This can be disabled in your /etc/wsl.conf
[automount]
enabled = false
I found this nice root-fs tarball, I’m tinkering right now with it but the systemd-networkd (in WSL) is giving me a headache.
https://fra1lxdmirror01.do.letsbuildthe.cloud/images/debian/trixie/amd64/default/20251210_08:05/rootfs.tar.xz
This is btw the command which causes the C mount loop:
find / \( -name '*?.dpkg-dist' -o -name '*?.dpkg-old' -o -name '*?.dpkg-new' -o -name '*?.dpkg-bak' -o -name '*?.dpkg-del' -o -name '*?.ucf-dist' -o -name '*?.ucf-old' -o -name '*?.ucf-new' \) -exec rm -v {} +
These are obsolete dpkg and ucf config file backups/alternatives , unlikely to exist on any Windows system. But yeah, to be sure, when implementing WSL2 support, we should detect it (hopefully possible with systemd-detect-virt) and unmount all host system mounts that WSL2 can provide.
Thanks for that tip and for your continued work on this!
I found somebody who had the same problem:
Run multiple WSL2 VMs with systemd-networkd (which will be used if you activate systemd via/etc/wsl.conf. systemd is necessary for DietPi.)
As far as you restart networking on the running system WSL DHCP fails to assign a new IP (or even when you run multiple isntances in parallel)
The fix is to assign new routes without restarting the network service, but the catch is:
You can not use dietpi’s internal tools to config the network since it’s relying on ifupdown, and not systemd networkd.
here is the full article:
I did not test this yet.
In the article he’s using some ruby code to generate a one-shot systemd service, he just automates it with ruby to deploy it on all his VM’s. It’s a service like
[Unit]
Description=Add static IPs to eth0
After=network-online.target
Wants=network-online.target
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "ip addr add 172.24.0.11/20 dev eth0 || true"
[Install]
WantedBy=multi-user.target
OK I found another solution, without systemd-networkd etc. You can just mask the services (why did I not think about this earlier?) and WSL will not re-enable them again after restart. If they are only deactivated they will be alive again on next start of the VM.
So here is what I did:
Install Debian via root-fs tarball via powershell (I have already Debian installed via WSL and you can not install a second one by default. This is my workaround):
wsl --import DietPi M:\WSL M:\Downloads\rootfs.tar.xz
DietPi is the name of the WSL instance, M:\WSL is the path where the vhdx of the VM will be stored. The last argument is the path to your tarball.
I started then the VM, installed nano (apt install nano) and created the wsl config file nano /etc/wsl.conf with the contents:
[boot]
systemd=true
[network]
generateResolvConf=false
[automount]
enabled=false
automounts false prevent WSL from mounting any windows partitions.
After that I stopped and masked networkd and resolved.
Then stop WSL via powershell wsl --shutdown, restart the VM and follow the instructions from the docs
apt update
apt install -y curl ca-certificates systemd-sysv
bash -c "$(curl -sSfL 'https://raw.githubusercontent.com/MichaIng/DietPi/master/.build/images/dietpi-installer')"
I choose then VM, it hang on some point, it needed dpkg --configure -a whichI did in a second terminal. It ran then through ![]()
On reboot the first install script started and complained that no journal is present.
But now it’s up and running.
After the init installation it hang up on the cron service
damn!
It also can not create an UUID for the survey. Let’s what else is broken.
edit: the workaround for cron would be to use Windows Task Scheduler. Also systemd timers would not work since WSL lacks a init environmnt.