wsl.rst
changeset 2534 f63a05c1ce4f
parent 2533 3d0d8ed75cb5
child 2535 6f7f3c2f40e1
equal deleted inserted replaced
2533:3d0d8ed75cb5 2534:f63a05c1ce4f
    46   wsl -u root -d alpine -- ls
    46   wsl -u root -d alpine -- ls
    47   wsl -u root -e sh -c "service apache status || service apache start"
    47   wsl -u root -e sh -c "service apache status || service apache start"
    48 
    48 
    49 https://docs.microsoft.com/en-us/windows/wsl/wsl-config
    49 https://docs.microsoft.com/en-us/windows/wsl/wsl-config
    50   Ways to run WSL.
    50   Ways to run WSL.
       
    51 
       
    52 Installing WSL distor second time
       
    53 =================================
       
    54 
       
    55 Microsoft provides certain Linux distros out of the box::
       
    56 
       
    57   wsl --list --online
       
    58   NAME            FRIENDLY NAME
       
    59   Ubuntu          Ubuntu
       
    60   Debian          Debian GNU/Linux
       
    61   kali-linux      Kali Linux Rolling
       
    62   openSUSE-42     openSUSE Leap 42
       
    63   SLES-12         SUSE Linux Enterprise Server v12
       
    64   Ubuntu-16.04    Ubuntu 16.04 LTS
       
    65   Ubuntu-18.04    Ubuntu 18.04 LTS
       
    66   Ubuntu-20.04    Ubuntu 20.04 LTS
       
    67 
       
    68 After the installation you will have an executable ``NAME.exe`` for convenient entering into
       
    69 distro, compare::
       
    70 
       
    71   $ wsl -d NAME CMD
       
    72   $ NAME.exe CMD
       
    73 
       
    74 You install such distros via::
       
    75 
       
    76   wsl --install NAME
       
    77 
       
    78 What if you want 2 Debian distros? Unfortunately you have to deal with rootfs:
       
    79 
       
    80 * either export existing WSL distro::
       
    81 
       
    82     wsl --export Alpine alpine.tar
       
    83     wsl --import alpine-copy 'c:\srv\wsl\alpine-copy' alpine.tar
       
    84 
       
    85 * or use LXC / OCI rootfs (like one from https://alpinelinux.org/downloads/ or
       
    86   http://cdimage.ubuntu.com/ubuntu-base/releases/)::
       
    87 
       
    88     wget https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-minirootfs-3.16.0-x86_64.tar.gz
       
    89     wsl --import alpine-x 'c:\srv\wsl\alpine-x' alpine-minirootfs-3.16.0-x86_64.tar.gz
       
    90 
       
    91 I'd suggest to use Ubuntu "base" images instead (less bloated than "cloud" images):
       
    92 
       
    93 * http://cdimage.ubuntu.com/ubuntu-base/releases - base images
       
    94 * https://cloud-images.ubuntu.com/releases/ - cloud images
       
    95 
       
    96 You download rootfs and import it::
       
    97 
       
    98   wget http://cdimage.ubuntu.com/ubuntu-base/releases/22.04/release/ubuntu-base-22.04-base-amd64.tar.gz
       
    99   wsl --import my-ubuntu c:\wsl\my-ubuntu ubuntu-base-22.04-base-amd64.tar.gz --version 2
    51 
   100 
    52 wslconfig utility
   101 wslconfig utility
    53 =================
   102 =================
    54 
   103 
    55 List distros::
   104 List distros::
   114 
   163 
   115 https://github.com/Microsoft/WSL/blob/master/CONTRIBUTING.md
   164 https://github.com/Microsoft/WSL/blob/master/CONTRIBUTING.md
   116 https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp
   165 https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/wsl.wprp
   117 https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1
   166 https://github.com/Microsoft/WSL/blob/master/diagnostics/collect-wsl-logs.ps1
   118 
   167 
       
   168 https://msrc-blog.microsoft.com/2018/12/10/first-steps-in-hyper-v-research/
       
   169 https://msrc-blog.microsoft.com/2019/09/11/attacking-the-vm-worker-process/
       
   170 
   119 Custom WSL 2 Linux kernel
   171 Custom WSL 2 Linux kernel
   120 =========================
   172 =========================
   121 
   173 
   122 Register kernel in ``/etc/wsl.conf``::
   174 Register kernel in ``/etc/wsl.conf``::
   123 
   175