netstack

wsl windows subsytem for linux

wsl –list –verbose #to check all the installed distro wsl –unregister Ubuntu #to remove the distro

The ext4.vhdx file will be deleted, and you can again run Ubuntu.exe setup file to start over.


- ext4.vhdx filenames by referencing the registry, ex: powershell:
```powershell
(Get-ChildItem HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss | ForEach-Object {Get-ItemProperty $_.PSPath}) | select DistributionName,BasePath,VhdFileName

wsl portproxy

wsl portproxy from windows os



Backup / Move

To move a WSL (Windows Subsystem for Linux) distribution to a new computer, you can export it as a .tar file and then import it on the new machine. This process involves using the wsl –export command to create the backup, transferring the file, and then using wsl –import to restore it.

Steps to Backup and Move WSL:

  1. Backup on the old machine:
    • Open PowerShell or Command Prompt as an administrator.
    • Stop the WSL instance: If the distribution is running, stop it using
        wsl --shutdown or wsl --terminate <DistributionName>
      
    • Export the distribution command to create a .tar backup. Replace with the name of your WSL distribution (e.g., "Ubuntu-20.04") and with the desired path and filename for the backup (e.g., "C:\backups\ubuntu_backup.tar").
        wsl --export <DistributionName> <FileName>
      
  2. Transfer the generated .tar file to the new computer using your preferred method (e.g., USB drive, network share).
  3. Import on the new machine:
    • Open PowerShell or Command Prompt as an administrator on the new computer.
    • Unregister any existing distribution with the same name: if needed:
        wsl --unregister <DistributionName>
      
    • Import the distribution: Use the import command. Replace with a new name for the distribution, with the desired directory for the installation (e.g., "D:\WSL\Ubuntu"), and with the path to the .tar file.
        wsl --import <NewDistributionName> <InstallLocation> <BackupFilePath>
      
  4. Set the default user: If needed, configure the default user for the imported distribution using ubuntu.exe config –default-user .
  5. Launch the distribution: Run to start the imported distribution.
      wsl --distribution <NewDistributionName>
    

Important Notes: