Cloning WSL Distributions

Published: (February 18, 2026 at 07:29 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

Why clone a WSL distribution?

You’ve spent hours setting up a WSL distribution—installing packages, configuring your shell, and tuning your development environment. Before you try something risky (major version upgrade, new tool, or an isolated project), you can create a clone to protect your working setup.

Export & import (tar)

The basic workflow is:

# Export the current distro to a tar file
wsl --export Ubuntu C:\Temp\ubuntu-clone.tar

The tar file contains a complete snapshot of the filesystem (packages, user accounts, configuration files, home directory, etc.).
For large distributions this may take a few minutes and the tar size will be roughly equal to the used disk space inside the distro.

# Import the tar as a new distribution
wsl --import Ubuntu-Dev "D:\WSL\Ubuntu-Dev" C:\Temp\ubuntu-clone.tar

Arguments

ArgumentMeaning
Ubuntu-DevName of the cloned distribution
D:\WSL\Ubuntu-DevDirectory where the new VHDX will be created
C:\Temp\ubuntu-clone.tarTar file produced in the export step

Restoring the default user

When importing from a tar archive, WSL logs in as root by default. Set the default user by editing /etc/wsl.conf:

# Start the clone as root
wsl -d Ubuntu-Dev -u root

# Append the user section if it does not exist
grep -q "^\[user\]" /etc/wsl.conf 2>/dev/null || cat >> /etc/wsl.conf *
0 views
Back to Blog

Related posts

Read more »

Renaming WSL Distributions

Renaming WSL Distributions – A Complete Guide You installed Ubuntu from the Microsoft Store and WSL named it Ubuntu‑24.04. You installed another one and got Ub...

Apex B. OpenClaw, Local Embeddings.

Local Embeddings para Private Memory Search Por default, el memory search de OpenClaw envía texto a un embedding API externo típicamente Anthropic u OpenAI par...