Posts

Showing posts with the label WSL

Remove Windows executables from your WSL Linux path

Windows and WSL interoperability is fantastic but sometimes you end up with unintended side effects.  When coding I like to have specific tools and configurations for each environment.  Otherwise, I can get pathing or other problems.   Why is it complaining about a '\r' character when I'm running Linux?  It is because some Linux tools and Windows files collide with each other. With that in mind, you may wish to remove the Windows executables from your Linux $PATH.  There are two ways to configure the WSL to not import the Windows $PATH. You can disable or enable it on a per WSL instance basis.  You can globally configure WSL so that the PATHbehavior is the same for all WSL instances you have configured. Configuring individual WSL instances with wsl.conf Each individual WSL instance looks in its own configuration file   /etc/wsl.conf  that may not be created by default in your WSL instance. 1. Edit the existing /etc/wsl.conf .  Creat...

Address Pools and Interfaces for Docker and WSL and Windows

Image
Docker Desktop and WSL2 integration on Windows 10/11 "just works" in many situations but feels like magic. I needed a map of the networks and names to understand why I needed proxies, port forwarders, and projected ports. May this be useful to you also :-) The Windows 10/11 machine in this diagram is known as Z820. This diagram is an outside-looking-in topology. There are multiple networks and different name resolutions for the same names depending on where you are in the network. In some places, the same hostname is resolved to different IPs if you use DNS vs the host table, /etc/hosts Click to Enlarge This diagram is a simplified version of the previous one with the WSL network and associated Linux installations removed. Click to Enlarge Video YouTube Windows WSL2 Docker Node Pool and Desktop Networks and Names The Six Networks in this diagram The network IP ranges in the diagram above are those of the default Docker / WSL installations and can be adjusted via various mech...

Moving a WSL virtual disk to another drive with automation

Image
I have a couple disk drives in my experimental box and I want to move the WSL disks to one of the secondary, non-boot, drives. I want to use the bandwidth that exists on multiple drives on multiple buses and get better performance for my WSL instances. I do the same thing for VMS that I run in VMware Workstation or Fusion. All the text on this page came from the video transcript of    Moving a WSL virtual disk to another drive WSL Distributions WSL is managed as registered distributions. Each one of those distributions has an associated vhdx. Those are located on the C:\ drive so also I tend to run out of C:\ space because I do all kinds of other things there. We're going to need to do a couple tweaks to move them and make this work. There's no way to edit this easier to do what we want or make the change with just a config file change. Migration Discussion We're going to destroy the existing registration and recreate the registration with the vhd somewhere else. Term...

Run the Kali-Linux GUI in WSL2 with only two lines of code

Image
Microsoft has added graphics support to Windows WSL2 by adding a new graphical component called WSLg. The thing rocks but Linux can be fiddly for setting up what is essentially a remote desktop.  It turns out that the Kali team created a single package that handles everything,  kali-win-kex . Just install kali-win-kex and run it. Video Steps Upgrade WSL to support GUI integration Update your WSL to make sure  WSLg  is installed and is on the latest version. This code exists in the move-distribution.ps1 script wsl --update Install kali-win-kex Option 1: Enable kali-win-kex and run the Kali GUI without any upgrades From the Kali-Linux shell prompt # install the Kali remote destop server sudo apt update sudo apt install -y kali-win-kex # start the Kali remote desktop with Windows integration Option 2: Run updates, install all packages, enable kali-win-kex, run the Kali GUI Install package  kali-win-kex  and add...

Understanding your WSL2 RAM and swap - Changing the default 50%-25%

Image
The Windows Subsystem for Linux operates as a virtual machine that can dynamically grow the amount of RAM to a maximum set at startup time.  Microsoft sets a default maximum RAM available to 50% of the physical memory and a swap-space that is 1/4 of the maximum WSL RAM.  You can scale those numbers up or down to allocate more or less RAM to the Linux instance. The first drawing shows the default WSL memory and swap space sizing. The images below show a developer machine that is running a dev environment in WSL2 and Docker Desktop.  Docker Desktop has two of its own WSL modules that need to be accounted for.  You can see that the memory would actually be oversubscribed, 3 x 50% if every VM used its maximum memory.  The actual amount of memory used is significantly smaller allowing every piece to fit. Click to Enlarge The second drawing shows the memory allocation on my 64GB laptop. WSL Linux defaul...

Single Node Kubernetes with Docker Desktop

Image
You can run Single-node Linux Kubernetes clusters with full Linux command line support using Docker Desktop and Windows WSL2.  Docker Desktop makes this simple. This is probably obvious to everyone. I wrote this to capture the commands to use as a future reference. There is another article that discusses  Creating a multi-node Kubernetes Cluster on a single machine using Kind http://joe.blog.freemansoft.com/2020/07/multi-node-kubernetes-with-kind-and.html Windows 10 / 11 - WSL2 - Docker The simplest way to run Kubernetes Windows 10 is with the Docker Desktop and WSL2 integration.  Docker will prompt to enable WSL2 integration during installation if you are running a late enough version of Windows 10 or any Windows 11. Prerequisites Docker is installed with WSL2 integration enabled.  The docker command operates correctly when you type a docker  command in a WSL linux command prompt. Install, Enable and Verify Install Docker Enab...

Java 8 development on Linux/WSL with Visual Studio Code on Windows 10

Image
Linux on Windows via WSL 2, has become a great development environment when targeting cloud containers and functions.  Windows has a shot at becoming the favorite desktop for users building Linux applications. Visual Studio Code (VSCode) is a great IDE. VSCode can run in a split GUI/Server fashion with the GUI in Windows and all the full SDLC executing on Linux. Development happens inside the Linux, WSL2 leveraging VS Code Server The GUI happens as a real part of the Windows Desktop and connects to Remote  VSCode servers, in this case in WSL Linux Ooh A Video Java Development VSCode's Java integration is built on top of Java 11.  This means you probably will end up with Java 11 JDK installed in WSL2 Linux and in Windows.  By default, applications will be Compiled with Java 11.   You can target  application compilation against versions other than the one used by the IDE. This is done by installing the needed Java versions on the Linux side and adding th...