Skip to content

TamerOnLine/wsl2-desktop

WSL2 Ubuntu 22.04 DevOps Environment

WSL Platform Use GitHub stars License Repo size


Architecture Overview


Overview

This document provides a professional DevOps-oriented setup guide for running Ubuntu 22.04 inside Windows using WSL2.

The goal of this guide is to create a clean, reproducible, optimized development environment suitable for:

  • DevOps engineering
  • Backend development
  • Cloud tooling
  • Containers and Kubernetes
  • Infrastructure automation

The guide includes:

  • WSL2 installation
  • Ubuntu deployment
  • systemd enablement
  • performance tuning
  • service optimization
  • GUI support via WSLg
  • backup and distribution management

Documentation


Features

  • ⚡ Optimized WSL2 configuration
  • 🖥 Linux GUI support via WSLg
  • ⚙ systemd enabled environment
  • 📦 Backup and distribution management
  • 🛠 DevOps-ready development environment

Table of Contents


Quick Start

For a quick installation guide, see:

Quick Start Guide

Install WSL and Ubuntu quickly:

wsl --install -d Ubuntu
# restart Windows if prompted
wsl -d Ubuntu

Update the Ubuntu system:

sudo apt update && sudo apt upgrade -y

Enable systemd support:

sudo nano /etc/wsl.conf

Add the following configuration:

[boot]
systemd=true

Restart WSL to apply the changes:

wsl --shutdown

Architecture

Windows Host
│
├─ WSL2 Virtualization Layer
│
└─ Ubuntu 22.04 Environment
     ├─ systemd
     ├─ CLI Development Tools
     ├─ DevOps Tooling
     └─ Linux GUI Apps (WSLg)

System Requirements

Minimum requirements:

  • Windows 11 or Windows 10 with WSLg
  • WSL2 support enabled
  • Administrator PowerShell access
  • Internet connectivity

Recommended for development workloads:

  • 16 GB RAM
  • 4+ CPU cores
  • SSD storage

Install WSL

Open PowerShell as Administrator:

wsl --install

Restart Windows after installation.

Verify installation:

wsl --status
wsl -l -v

Update WSL:

wsl --update

Set WSL2 as default:

wsl --set-default-version 2

Install Ubuntu

Install Ubuntu distribution:

wsl --install -d Ubuntu

List installed distributions:

wsl -l -v

Launch Ubuntu:

wsl -d Ubuntu

Import Ubuntu RootFS (Advanced)

Download Ubuntu root filesystem:

https://cloud-images.ubuntu.com/wsl/jammy/current/

Import distribution manually:

wsl --import <DistroName> <InstallPath> <TarFile> --version 2

Example:

wsl --import Ubuntu-Dev M:\WSL\Ubuntu-Dev ubuntu-jammy.rootfs.tar.gz --version 2

Update System

Inside Ubuntu:

sudo apt update && sudo apt upgrade -y

Create Non‑Root User

sudo adduser <username>
sudo usermod -aG sudo <username>

Enable systemd

Edit configuration file:

sudo nano /etc/wsl.conf

Add the following:

[boot]
systemd=true

[user]
default=<username>

Apply changes:

wsl --shutdown

Configure WSL2 Resources

Create or edit the following file on Windows:

C:\Users\<username>\.wslconfig

Example configuration:

[wsl2]
memory=8GB
processors=4
swap=2GB
localhostForwarding=true

Apply configuration:

wsl --shutdown

Disable Unnecessary Services

WSL environments do not require several background services. Disabling them reduces resource consumption.

Disable services:

sudo systemctl disable snapd
sudo systemctl disable bluetooth
sudo systemctl disable apport
sudo systemctl disable cups

Stop services immediately:

sudo systemctl stop snapd bluetooth apport cups

Install Minimal GUI Applications (WSLg)

Install core graphical tools:

sudo apt install -y \
nautilus \
gnome-terminal \
gedit \
eog \
gnome-control-center \
xdg-user-dirs

Initialize user directories:

xdg-user-dirs-update

Disable automount for virtual devices:

gsettings set org.gnome.desktop.media-handling automount false
gsettings set org.gnome.desktop.media-handling automount-open false

Test GUI:

nautilus ~

Create GUI Launch Script

Create user binary directory:

mkdir -p ~/bin

Create script:

nano ~/bin/gui.sh

Script:

#!/bin/bash

dbus-run-session nautilus ~ >/dev/null 2>&1 &
dbus-run-session gnome-terminal >/dev/null 2>&1 &

Make executable:

chmod +x ~/bin/gui.sh

Run:

gui.sh

Add ~/bin to PATH

echo 'export PATH="$HOME/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Environment Verification

Verify environment configuration:

lsb_release -a
uname -a
whoami

Backup and Distribution Management

Create directories:

mkdir M:\WSL\Ubuntu-Dev
mkdir M:\WSL\Ubuntu-Prod

Export distribution:

wsl --export <DistroName> backup.tar

Import distribution:

wsl --import <NewDistroName> <InstallPath> backup.tar --version 2

Remove distribution:

wsl --unregister <DistroName>

Shutdown WSL:

wsl --shutdown

Troubleshooting

Restart WSL:

wsl --shutdown

Update WSL:

wsl --update

List distributions:

wsl -l -v

Contributing

Contributions are welcome.

If you would like to improve the documentation or add new features, please read the contribution guidelines:

CONTRIBUTING.md


Security

If you discover a security issue, please follow the security policy described in:

SECURITY.md


Conclusion

This guide provides a clean, optimized DevOps-ready Ubuntu environment inside WSL2.

The setup enables:

  • reproducible development environments
  • lightweight Linux virtualization
  • DevOps tooling support
  • GUI Linux applications on Windows

This workflow is ideal for developers, DevOps engineers, and cloud infrastructure professionals.

About

WSL2 Ubuntu 22.04 Desktop & Development Environment Setup Guide

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors