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 and Modules on WSL Ubuntu

Miniconda

  1. Download miniconda Linux installer to wls ubuntu instance:
    wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh 
  2. Run the downloaded script to install miniconda, yes to initilization set up.
    bash Miniconda3-latest-Linux-x86_64.sh
    Exit and start terminal after installation to enter the conda environment.

Python modules

conda install numpy scipy matplotlib pygraphviz pandas xlrd openpyxl

Compilers:

This is a little complicated. Currently PB solver delphi requires an old version of gfortran. That's the reason we wanted to install a conda version of compiler. Since we will adopt the new delphi which is compilable in C++, I decided to stick with the gcc from ubuntu OS.

Microsoft Visual Studio 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.

VS Code installation

 

Other software under WSL

XLauncher

Pymol