windows wsl - ghdrako/doc_snipets GitHub Wiki

WSL2

when you use WSL integration, two distros will be created for you (docker-desktop & docker-desktop-data) image

To reach their file system, you need to access it over network

\\wsl$\docker-desktop
\\wsl$\docker-desktop-data
wsl --version
wsl --update
wsl -l -v
wsl.exe --list --verbose --all
wsl.exe --list –running
wsl.exe --distribution Ubuntu-20.04
wsl.exe --set-default Ubuntu-20.04
wsl -d docker-desktop-data

Gdzie sa trzymane wolumeny dokerowe dla wsl2?

W exploratorze windows mozna wpisac:

\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\ansible_vol\_data\playbooks
\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes

C:\Users\username\AppData\Local\Docker\wsl\distro\ext4.vhdx
%LocalAppData%
C:\Users\akepka\AppData\Local\Docker\wsl\data\ext4.vhdx

Container data:

\\wsl$\docker-desktop-data\version-pack-data\community\docker\containers\376a0b311b09b287664d7258cb0620f8b1ed9cf986aa1de4d8e53f6e98c6c93d\resolv.conf

wsl --list --online # lista dostepnych dystrybucji do sciagniecia

Moving vhdx to another location

The .vhdx file can be moved by using the --export and --import options: https://docs.microsoft.com/en-us/windows/wsl/reference ; MicrosoftDocs/WSL#412

wsl --shutdown
wsl -l -v
wsl --export <DistroName> <PathToTarArchive>
wsl --unregister <DistroName>
wsl --import <DistroName> <PathToDistroNewDirectory> <PathToTarArchive>
wsl -l -v

You'll get the from the output of wsl -l -v.

How to Copy Files From Windows to Ubuntu in WSL on the Same Host

  • Using /mnt
$ sudo ls /mnt/*
sudo cp /mnt/c/Users/<user>/Documents/linuxtest.txt .
  • Using SSH and WinSCP
$ sudo apt remove openssh-server
$ sudo apt install openssh-server
$ sudo service ssh start
$ sudo nano /etc/ssh/sshd_config
# set the PermitRootLogin and the PasswordAuthentication to Yes

# check ip addres:
$ sudo apt install net-tools
$ ifconfig

Next install and configure winscp

⚠️ **GitHub.com Fallback** ⚠️