A PowerShell script to provision Ubuntu‑24.04 on WSL2 with Python, Docker, Zsh, and more — idempotent & user‑configurable.
- Windows 10/11 with WSL enabled (Admin PowerShell, elevated).
- PowerShell 5.1 or later.
This runs the script from GitHub directly. Make sure you're in an elevated PowerShell window (Run as Administrator).
irm https://raw.githubusercontent.com/ramkrishs/wsl2-bootstraper/main/setup-wsl.ps1 | iexYou’ll be prompted to:
-
Choose or create a UNIX username & password
-
Provide Git name/email
-
Select optional components:
- ✅ Docker
- ✅ Zsh + Oh My Zsh
- ❌ CUDA (optional)
- ✅ systemd
git clone https://github.com/ramkrishs/wsl2-bootstraper.git
cd wsl2-bootstraper
.\setup-wsl.ps1Make sure you're in an elevated PowerShell window (Run as Administrator).
You’ll be prompted for a UNIX username, password, Git identity, and whether to install:
- systemd support
- Docker
- CUDA (optional)
- Zsh + Oh My Zsh
-
Checks/installs WSL & Ubuntu‑24.04, converts to WSL2 if necessary.
-
Creates (or skips) a sudo‑enabled UNIX user, sets default user via registry.
-
Configures passwordless sudo for the new user.
-
Writes
/etc/wsl.confto enable systemd. -
Bootstraps Ubuntu via an embedded Bash script:
- core dev tools
- Git config
- Docker (if chosen)
- Python via pyenv (latest 3.12.x)
- pip, Poetry, pipx, uv
- CUDA toolkit (optional)
- Zsh + Oh My Zsh with Powerlevel10k & plugins
-
Appends user
.zshrcwith:export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init --path)" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" export PATH="$HOME/.local/bin:$PATH"
-
Validates default user, ensures root vs user installs are isolated.
-
Optionally launches Ubuntu terminal when done.
- Ensure your password is correctly passed — check passwordless sudo config.
- Double-check your
$HOMEpaths in zshrc to avoid Windows path contamination. - WSL2 memory may balloon; use
.wslconfigto cap VM RAM ([github.com][1], [reddit.com][2], [stackoverflow.com][3]).
-
Default user isn’t being set correctly? Check that registry
DefaultUidmatches your new user's UID. -
pyenvnot loading or$HOMEwrong? Make sure you’re sourcing the appended.zshrcunder the correct user in WSL. -
Memory not reclaimed? Use a
.wslconfigwithmemory=...GB, thenwsl --shutdown([stackoverflow.com][3]).
PRs welcome! Please:
- Keep ASCII‑only PowerShell.
- Maintain idempotency.
- Add tests around
.zshrc& path injection.