WSL2: Difference between revisions
Appearance
mNo edit summary |
|||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
== Links == | == Links == | ||
* https://docs.microsoft.com/en-us/windows/wsl/wsl-config | * https://docs.microsoft.com/en-us/windows/wsl/wsl-config | ||
* https://medium.com/@joe.njenga/47-claude-code-wsl-tricks-every-windows-user-should-know-5d42aaee2d93 | |||
== WSL startup speed == | == WSL startup speed == | ||
| Line 149: | Line 150: | ||
# uncomment | # uncomment | ||
%wheel ALL=(ALL:ALL) NOPASSWD: ALL | %wheel ALL=(ALL:ALL) NOPASSWD: ALL | ||
# :wq to save | |||
touch /etc/wsl.conf | touch /etc/wsl.conf | ||
vi /etc/wsl.conf | |||
[user] | [user] | ||
default=marcluer | default=marcluer | ||
</pre> | </pre> | ||
[[Category:Windows | [[Category:Windows]] | ||
[[Category:Windows | [[Category:Windows]] | ||
Latest revision as of 13:39, 17 September 2025
Links
- https://docs.microsoft.com/en-us/windows/wsl/wsl-config
- https://medium.com/@joe.njenga/47-claude-code-wsl-tricks-every-windows-user-should-know-5d42aaee2d93
WSL startup speed
wsl --shutdown wsl --list --running wsl "dmesg"
Config
/etc/wsl.conf
[boot] systemd=false [automount] enabled = false # /mnt/C
C:\Users\UserName\.wslconfig
[wsl2] memory=4GB # Limits VM memory in WSL 2 to 4 GB processors=2 # Makes the WSL 2 VM use two virtual processors [experimental] networkingMode=mirrored # IPv6 support!!!
Networking
Network bridge to Ethernet Adapter
- Enable Hyper-V
Dism /online /enable-feature /featurename:Microsoft-Hyper-V -All /LimitAccess /ALL
- Install Hyper-V Windows features - "Turn Windows features on or off":
Hyper-V Management Tools > All Hyper-V Platform > All
- Script after every logon
set-vmswitch -name wsl -NetAdapterName Ethernet
- get new DHCP IP for WSL2
sudo ip addr flush dev eth0 sudo dhclient eth0
WSL IPs
wsl hostname -I netsh interface ipv4 show neighbors
fstab
z: /mnt/z drvfs rw,relatime 0 0
mount -t drvfs '\\server\share' /mnt/share
Docker in WSL
- install docker on linux
- add to ~/.bashrc
# Start Docker daemon automatically when logging in if not running.
RUNNING=`ps aux | grep dockerd | grep -v grep`
if [ -z "$RUNNING" ]; then
sudo dockerd > /dev/null 2>&1 &
disown
fi
Other
Using New Windows Terminal
- profiles.json
- set defaultProfile to Ubuntu
- for linux home dir:
"commandline" : "wsl.exe ~ -d Ubuntu-20.04",
Show DHCP Leases
wsl.exe ~ -d Ubuntu ssh -t root@router cat /tmp/dhcp.leases && exec bash
Running Linux Commands
- using bash.exe
bash.exe -c "jupyter-notebook ; /bin/bash"
- using wsl
wsl jupyter-notebook &
Multiple Distro Instances
* Settings -> Apps -> Ubuntu -> Advanced -> Reset to initial state wsl --list wsl --export Ubuntu-20.04 Ubuntu_fresh_rootfs.tar.gz wsl --import DistroName InstallationPath Ubuntu_fresh_rootfs.tar.gz wsl -d DistroName
- alternative: https://github.com/yuk7/wsldl
Alpine + WSL 1 for quick SSH connections
https://dl-cdn.alpinelinux.org/alpine/latest-stable/releases/x86_64/ download alpine-minirootfs-...-x86_64.tar.gz save at C:\WSL mkdir C:\WSL\alpine cd C:\WSL wsl --import Alpine C:\WSL\Alpine\ alpine-minirootfs-...-x86_64.tar.gz --version 1 wsl -d Alpine apk update apk add openssh sudo adduser marcluer adduser marcluer wheel visudo # uncomment %wheel ALL=(ALL:ALL) NOPASSWD: ALL # :wq to save touch /etc/wsl.conf vi /etc/wsl.conf [user] default=marcluer