Skip to main content

How to install WSL (Windows Subsystem Linux)

How to install WSL (Windows Subsystem Linux) and MCCE dev tools

WSL

WSL Installation

The official WSL installation instruction can be found on MIcrosoft website. https://learn.microsoft.com/en-us/windows/wsl/install

The following is the my WSL installation on WIndows 10 Pro.

  1. Open Powershell as Administrator, run
    wsl --install
    This installation will install Ubuntu under WSL.
  2. Setting up user for Linux. After the reboot, WSL will ask for setting up the first user.
  3. While wsl is open, right click on the penguine icon on task bar to pin it so that it is easy to start wsl linux next time.

From WSL, to access the files on the host system (Windows 10), use the path /mnt/c for the C drive.

From the host (Windows), to access the files on WSL, use the path \\wsl.localhost\Ubuntu

To check WSL version, run wsl -l -v under PowerShell.

To check Linux version, run cat /etc/issue under Linux

WSL Virtual disk optimization

Linux under WSL uses a dynamic virtual disk. The virtual disk may be even larger than the physical disk on the host. In my case, the virtual disk is 1TB while I only have a 500 GB disk:

image.png

The actual usage after initial installation is about 2 GB, and the host will host will allocate more physical disk to it as needed.

image.png

However, once allocated, the virtual disk never shrinks. To shrink the virtual disk, I will need to do it through PowerShell.

  1. Open PowerShell as Adminostrator.
  2. Shutdown wsl instance: wsl --shutdown
  3. Run command
    Optimize-VHD -Path  C:\Users\Junjun\ Mao\AppData\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\ext4.vhdx  -Mode Full

 

Linux customization

  • Home directory: Add cd to the user .bashrc so the terminal window starts at the home directory.
  • Update Linux:
    sudo apt update
    sudo apt upgrade
    sudo apt install vim aptitude
  • Build essential
    sudo aptitude install build-essential

Conda Python environment and Modules

Miniconda

Python modules

Compiler

Microsoft Visual Code

I am moving from Pycharm to Code due to

  • Pycharm crashes at the start on my desktop.
  • The ability of Code to code remotely vs ssh and wsl.

Other software under WSL

XLauncher

Pymol