Ubuntu on WSL2

Enable WSL

  1. Open cmd or powershell :
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

And restart the computer

  1. Download and install WSL2 Linux kernel update package for x64 machines
  2. Set WSL 2 as your default version

wsl –set-default-version 2

  1. Open the Microsoft Store and select your favorite Linux distribution. For ex Ubuntu
  2. If not, upgrade ubuntu to wsl 2

wsl –set-version ubuntu 2

  1. Activate this option to download all the last kernels and WSL related products

  1. Specify the Browser location (useful for aws sso for example) in .bashrc or equivalent

export BROWSER='/mnt/c/Program Files/Google/Chrome/Application/chrome.exe'

Install Windows Terminal

Install Windows Terminal from Microsoft Store

Powerline Fonts

Downloads recommended fonts for Powerlevel10k MesloLGS NF here :

https://github.com/romkatv/powerlevel10k#meslo-nerd-font-patched-for-powerlevel10k

And install the 4 font flavors.

Terminal Configuration

Update terminal configuration with this conf

Alternative configuration

{
    "guid": "{some-value}",
    "hidden": false,
    "name": "Ubuntu-20.04",
    "source": "Windows.Terminal.Wsl",
    "colorScheme": "One Half Dark",
    "fontFace": "MesloLGS NF",
    "commandline": "wsl.exe ~"
}

Create a file /etc/wsl.conf and add the following content :

[interop]
appendWindowsPath = false

then from admin Powershell to restart the machine :

wsl -t Ubuntu

Update Ubuntu shell to use ZSH

$ sudo apt update
$ sudo apt install git zsh -y

Install Oh my zsh

$ sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Some useful plugins

$ git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
$ git clone --depth=1 https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k

Open ~/.zshrc

# Use Powerlevel10k theme
ZSH_THEME="powerlevel10k/powerlevel10k"

# Use plugins
plugins=(git docker aws zsh-autosuggestions zsh-syntax-highlighting)

Install VS Code

  1. Install VS Code and use Github account for retrieving saved configuration in File / Preference / Settings Sync
  2. All extensions including WSL should be installed and terminal configured

Run kvm and virt-manager

sudo libvirtd -d
sudo virtlogd -d
sudo chmod 666 /dev/kvm
sudo virt-install --name=deepin-vm --os-variant=ubuntu20.04 --vcpu=2 --ram=2048 --graphics spice --location=/home/xenom/debian-11.2.0-amd64-netinst.iso --network bridge:virbr0

Run virtualbox

Compile and install kernel modules

sudo make -j $(nproc)
sudo make -j $(nproc) modules_install

sudo vim /etc/modules-load.d/modules.conf

Pas sur que cela fonctionne visiblement lié a systemd (https://wiki.archlinux.org/title/Kernel_module)

# /etc/modules: kernel modules to load at boot time.
# This file contains the names of kernel modules that should be loaded
# at boot time, one per line. Lines beginning with "#" are ignored.

vboxdrv
vboxnetflt
vboxnetadp
vboxpci

Load modules

sudo modprobe vboxdrv
sudo modprobe vboxnetflt 
sudo modprobe vboxnetadp

virtualbox

# a relancer a chaque changement de kernel
sudo apt install --reinstall virtualbox-dkms

Si conflit avec les modules sudo apt-get autoremove peut aider et relancer sudo apt install --reinstall virtualbox-dkms

https://falco.org/blog/falco-wsl2-custom-kernel/

Rechercher les options de compilations du kernel en cours

zgrep CONFIG_PROC_EVENTS= /proc/config.gz

Get IPs

export $HOSTIP = cat /etc/resolv.conf | grep nameserver | cut -d ' ' -f 2                                                                                                                                                                                                                                                           ✔

export $WSLIP = ip addr | grep eth0 | cut -d ' ' -f 6 | tail -1 | cut -d '/' -f 1                                                                                                                                                                                                                                                  ✔