Windows Subsystem for Linux

Updated: September 28, 2024

Used for running VMs on Windows.

Windows Store has some distros, but we want NixOS!!
We mostly want to cover cli commands here.
Microsoft continues to underestimate the importance of documentation.

wsl
  -e, --exec                        # execute command in the WSL environment
  -i, --interactive                 # start an interactive shell in the WSL environment
  
  -l, --list                        # list available distros
    --all                           # list all available distros
    -o, --online                    # list all available distros that are online
    -q, --quiet                     # suppress output
    --running                       # list running distros
    -v, --verbose                   # verbose output
  
  -s, --set-defualt                 # set default distro
  -t, --terminate                   # terminate a running distro
  -u, --user <user>                 # run as specific user
  -v, --version                     # display version

  --                                # pass remaining arguments as-is.
  --cd <path>                       # sets the current working directory
  --debug-shell                     # open a wsl2 debug shell for disgnosis

  --export <distro> <filename>      # exports distro as tar file
    --vhd                           # export as a .vhdx file

  --help                            # display help message
  
  --import <distro> <installLocation> <filename>    # import distro from tar file
    --version                       # version to use for new distribution
    --vhd                           # import as a .vhdx file
  
  --install
    -n, --no-launch                 # do not launch distro after install
    --web-download                  # download distro from the web instead of Microsoft Store
    --no-distribution               # install wsl without distribution

  --manage
    -s, --set-sparse <bool>         # allow disk space to automatically be reclaimed

  --mount
    --bare                          # attach disk to wsl2 but do not mount it
    --name <name>                   # custom name for disk
    --options <options>             # mount options
    --partition <index>             # custom partition to use, defaults to whole disk
    --type <type>                   # disk type, defaults to ext4
    --vhd <disk>                    # specify disk to a virtual hard disk

  --set-default-version             # set default version for new distros ie wsl2
  --set-version                     # change version for distro
  --shutdown                        # shutdown all running distros and wsl2
  --status                          # display status of all running distros
  --system                          # launch a shell for the system distribution
  --unmount                         # unmount all disks from all mounted distros
  --unmount <disk>                  # unmount disk from all mounted distros
  --uninstall                       # uninstall the wsl2 distribution
  
  --update                          # update the wsl2 distribution
    --pre-release                   # update to the latest pre-release
    
  --unregister                      # unregister the wsl2 distribution deleting root fs