Random Musings...

Easily Importing distros in to WSL

Did you know you can take a docker container and WSL it?

We won’t go over installing WSL here, but either 1 or 2 works.

Quick How To

Lets say we want debian bookworm

  1. export CONTAINER='debian:bookworm'
  2. podman run -t $CONTAINER bash ls
  3. export CONTAINER_ID=$(podman container ls -a | grep -i $CONTAINER | awk '{print$1}')
  4. podman export $CONTAINER_ID > /mnt/c/Users/$USER/$(echo $CONTAINER | sed s/:/-/).tar

Then from Windows/Powershell

  1. wsl.exe --import --version 2 debian-bookworm 'C:\Users\$USER\debian-bookworm' 'C:\Users\$USER\debian-bookworm.tar'
First arg is the distro name

Second arg is the folder in which to store the distro

Third arg is the source .tar file for the distro

Setting a different User

export NEW_USER=imranh
useradd -m -G sudo -s /bin/bash "$NEW_USER"
passwd "$NEW_USER"
echo -e "[user]\ndefault=$NEW_USER" >> /etc/wsl.conf

Useful WSL Commands

List all WSL Instances/Distros

wsl --list --all --verbose

Shutdown an instance

wsl --shutdown <name>


wsl --terminate <name>

Delete WSL Instance

wsl --unregister <name>