Skip to content

Instantly share code, notes, and snippets.

@SomajitDey
Forked from 4wk-/README.md
Last active March 25, 2024 16:25
Show Gist options
  • Save SomajitDey/273f6c5efdcc7e88ebd7e677cd7a1795 to your computer and use it in GitHub Desktop.
Save SomajitDey/273f6c5efdcc7e88ebd7e677cd7a1795 to your computer and use it in GitHub Desktop.
Clean uninstall then reinstall of WSL on Windows 10, with systemD support

Uninstall then reinstall WSL on Windows 10 (clean way)

A - Uninstall wsl and related stuff

  1. In powershell (as admin)
# list all installed distros
wsl -l -v

# destroy distros
wsl --unregister Ubuntu
wsl --unregister Debian # and so on

 

  1. In Settings > Apps > Apps & Features
  • search for Ubuntu (then Debian, etc), and if something is found, click on uninstall
  • search for Linux, and if something is found, click on uninstall on all results

 

  1. In Start Menu > Turn Windows Features on or off
  • Untick Virtual Machine Platform checkbox
  • Untick Windows Subsystem for Linux checkbox

 

  1. Reboot
  • I might have reboot between step 2) and 3) as well.

B - Re-install and configure wsl to use systemD

The process of installing wsl have become super straightforward. And now WSLg gives you native GUI experience.

  1. 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).

 

  1. 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.

 

  1. 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

 

  1. 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).

 

  1. Although this link asks to install display drivers for enabling vGPU, it may not be necessary if running glxinfo | grep -i opengl shows D3D12 and the GPU name in the OpenGL Renderer part.

 

  1. If launging GUI apps throws dconf errors, add the following line to ~/.bashrc:
export $(dbus-launch)

 

  1. For networking between WSL2 and Windows see https://gist.github.com/SomajitDey/68e8cd639e3bf592bded035630cf86ec

 

  1. nautilus provides a great way to work simulataneously (in separate tabs) with files from Windows, WSL2 and a Remote server. To connect nautilus with Remote, follow this guide. Windows files can be easily mounted with Ctrl+L > /mnt/c/Users/<USER>/Downloads. Add the oft-used Windows and Remote folders to bookmarks for convenience.

 

  1. Check audio and video is working in WSLg. To test it open YouTube from firefox. To stop firefox from throwing xdg-settings not found errors, install xdg-utils with sudo apt install xdg-utils.

 

  1. Install basic Ubuntu apps: evince (pdf document viewer), eog (image viewer), gedit (text editor), gnuplot qt (not x11).

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.

@SomajitDey
Copy link
Author

After cleanly installing WSLg in Windows 10 (22H2) as above, launching gedit gave dconf errors. To remove those we need to add the following to ~/.bashrc:
export $(dbus-launch)

Courtesy: microsoft/WSL#10947 (comment)

@SomajitDey
Copy link
Author

Using latest drivers for Intel Iris Xe Graphics (built in 11th Gen Intel Core i5-1135G7), I didn't need to install any graphics driver as mentioned here. As stated here, running glxinfo | grep -i opengl showed D3D12 and my GPU name in the OpenGL Renderer part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment