# WSL Windows subsystem for linux

### install

[manual](https://learn.microsoft.com/en-us/windows/wsl/install-manual)

```
wsl --install Ubuntu-24.04 --name Number2
```

### backup and restore

[xda developers](https://www.xda-developers.com/how-back-up-restore-wsl/)

commands from link:

```powershell
# backup
wsl -l
wsl --export (distribution) (file path)

# remove
wsl -v
#-> uninstall dist form startmenu
wsl --unregister <distribution>

# restore
wsl --import (distribution) (install location) (file path)
wsl --distribution (distribution)
```

### move / clone distribution
not tested !!!
```powershell
wsl --export Debian C:\temp\Debian.tar
wsl --import MovedDebian C:\WSL\Debian C:\temp\Debian.tar --version 2
wsl --distribution MovedDebian
```



### settings

#### Mirrored Mode WSL2 Networking

from [superuser.com](https://superuser.com/questions/1679757/accessing-windows-localhost-from-wsl2/1835289#1835289)

Note: Requires Windows 11 23H2 or later

In Mirrored mode, localhost should "just work". To enable:

* Add the following to your `<windows_user_profile>/.wslconfig`:

  ```config
  [wsl2]
  networkingMode=mirrored
  #autoProxy=false # only if necessary ?
  ```

* Exit your WSL distribution
* Run `wsl --shutdown` from PowerShell then restart WSL

You should then be able to access services running in Windows via localhost.

Note that when running in Mirrored mode, mDNS will not work.

##### hosts configs:

edit `C:\Windows\System32\drivers\etc\hosts` in admin mode
add:
```
127.0.0.1	shop.local
```

#### non mirrored wsl2 mode

* simple check that the `./wslconfig` file is empty or at least `networkingMode=mirrored` is not set.

* check the im address: `wsl hostname -I`

TODO