I've been using wsl
(version 2) with genie
mod for years without issue, but one day, Windows 10 finally catch up on wsl
Windows 11 features and gives us a way to use systemD
natively.
I wanted to use the new "right way" to enable systemD
on Windows Subsystem for Linux (without genie
), and I also had a (probably related) infinite Windows RemoteApp error poping in.
- In powershell (as admin)
# list all installed distros
wsl -l -v
# destroy distros
wsl --unregister Ubuntu
wsl --unregister Debian # and so on
- In Settings > Apps > Apps & Features
- search for
Ubuntu
(thenDebian
, etc), and if something is found, click on uninstall - search for
Linux
, and if something is found, click on uninstall on all results
- In Start Menu > Turn Windows Features on or off
- Untick
Virtual Machine Platform
checkbox - Untick
Windows Subsystem for Linux
checkbox
- Reboot
- I might have reboot between step 2) and 3) as well.
The process of installing wsl have become super straightforward.
- Installing wsl - In powershell (as admin)
# install wsl
wsl --install
Then reboot and wait for the Ubundu installation to complete and ask for username (it might takes some time).
- Optional: Changing distribution - In powershell (as admin)
# list available distributions
wsl --list --online
# install favorite distro
wsl --install -d Debian
# set Debian as default
wsl --set-default Debian
NB: wsl --set-default-version 2
is not needed anymore.
- Enabling systemD support - Inside wsl
- Launch your distribution
- Edit
/etc/wsl.conf
(or create the file if it doesn't exist)
[boot]
systemd=true
# Optional: remove windows from PATH (autocompletion)
[interop]
appendWindowsPath = false
- Clean rebooting - In powershell (as admin)
# clean shutdown
wsl --shutdown
Great success! 🎉 You have now enabled systemD
in wsl
natively. You can test it with sudo systemctl status time-sync.target
(inside your Linux distribution).
NB: System wide configuration file .wslconfig
will not be deleted/reseted, you would have to do it manually.
Let me know if I missed anything, I'll be glad to update this gist.
Note: I'm a Win 10 user
Very helpful. What would you think about linking to the import/export documentation? And steps from https://learn.microsoft.com/en-us/windows/wsl/install-manual ?
Also, probably worth mentioning
wsl --update
.*If you are importing from an exported distribution, the default user will be
root
even if it was a different user when exported. Read the warning at the bottom of this section to learn how to set it back to the previous user: https://learn.microsoft.com/en-us/windows/wsl/basic-commands#change-the-default-user-for-a-distributionUPDATE
I was following these steps because I experienced the all too common "WSL2's wsl.exe hangs forever" symptom.
* These additional steps resolved my issues:
A.3.
step. I turned it back on manually, but I'm not sure if I needed to.wsl --update
.I'm not sure if both of these are required; I've yet to take the time to narrow it down.