commonplace
  • Commonplace
  • AWS
    • Control Tower
      • Building a Scalable and Secure Multi-VPC AWS Network Infrastructure
    • Talks / Articles
      • Encrypting Everything with AWS (SEP402)
      • The Tension Between Absolutes & Ambiguity in Security (SEC310)
      • Best practices for authoring AWS CloudFormation (DOP302-R1)
    • Useful Links
    • Notes
      • awscli
      • Cloudformation
        • Using Parameters
  • Infrastructure Security
    • Amazon Web Services
      • Tools
    • Tools
  • Security
    • Articles
      • If You're Not Doing Continuous Asset Management You're Not Doing Security | Daniel Miessler
      • Living Off the Land
        • Living Off The Land: Part 2
    • Cryptography
      • Shamir Secret Sharing Algorithm
    • Distros
      • REMnux
    • DoD
    • Email
    • GPG
    • Shodan
    • SSH
  • Resources
    • AWS Toolbox
    • CTF
      • AWS
    • Dev Setup
      • Windows Terminal
    • Documentation
      • MOCK Press Release Template
      • Design Document Template
    • Docker
      • Notes
      • Configure Docker w/TLS for WSL
    • Kubernetes
      • Raspberry Pi 4 (4GB) Cluster
    • Linux
      • zsh config
      • Users and Groups
    • Python
      • AWS
        • Lambda
      • Random Strings
    • Security News
    • Tools
    • Unity SSDLC
    • vscode
      • Cloudformation
    • Windows
      • WSL2
        • Scratchpad
        • Install a GUI (xfce)
        • Creating Additional WSL2 Instances
    • Youtubers
      • youtube-dl snippets
  • Lab
    • Building a Better Workstation
      • Notes / Guide
  • Misc
    • Notes
      • youtube-dl
  • Recipes
Powered by GitBook
On this page
  • Creating a Custom Distribution
  • Configure the base
  • Using our WSL distro as a template
  • Cleaning up
  • Acknowledgement

Was this helpful?

  1. Resources
  2. Windows
  3. WSL2

Creating Additional WSL2 Instances

PreviousInstall a GUI (xfce)NextYoutubers

Last updated 4 years ago

Was this helpful?

Get a rootfs. e.g. Ubuntu rootfs:

wsl.conf settings -

Configure global options with .wslconfig -

Creating a Custom Distribution

The first thing we’ll need is a root filesystem. Luckily Ubuntu make their WSL root filesystem available for download, which is available . For this walk-through I’ve created a directory on my Windows C: drive called “wsl”, we’ll place the rootfs files in c:\wsl\wslrootfs and the distros in c:\wsl\wsldistros\

  • Download the file above to the wslrootfs directory.

  • Run wsl.exe --import base-ubuntu C:\wsl\wsldistros\base-ubuntu\ C:\wsl\wslrootfs\ubuntu-20.04-server-cloudimg-amd64-wsl.rootfs.tar.gz

In this command base-ubuntu Is just a name you want to assign so for example a specific project. c:\wsl\wsldistros\base-ubuntu\ is the directory on your machine you want to place the virtual disk file for the distribution and then we have the distro file we downloaded

At this point you have a clean install of ubuntu 20.04 to use. You can then easily access each distribution you have available with Windows Terminal which places them all on a tab drop-down for easy access.

Configure the base

Configure it however you please. Consider using something like if this is going to be a fairly common process for you.

At this point, I'm specifying my naming convention moving forward. <date-modified>-<type>-<distro>

  • 20200714-base-ubuntu

Using our WSL distro as a template

Once we’ve got the tooling we want installed, we can export the rootfs for later use.

wsl --export baseubu c:\wsl\wslrootfs\20200714-base-ubuntu

Then we can create new instances based off this by importing the 20200714-base-ubuntu file we just created

wsl --import ViciousUnicorn c:\wsl\wsldistros\ViciousUnicorn\ c:\wsl\wslrootfs\20200714-base-ubuntu

and when we start it up, all our tools are in place :)

Cleaning up

Once you’re finished with it, it can just be removed with wsl.exe --unregister <Name>. This will delete the virtual disk file, however, as of writing the created folder is left behind.

Acknowledgement

Credit to Rory:

https://wiki.ubuntu.com/WSL#Installing_Ubuntu_on_WSL_via_rootfs
https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-per-distro-launch-settings-with-wslconf
https://docs.microsoft.com/en-us/windows/wsl/wsl-config#configure-global-options-with-wslconfig
here
Ansible
https://raesene.github.io/blog/2020/05/31/Custom_Pentest_Distributions_With_WSL2/