Upgrade WSL/WSL2 Ubuntu version to 20.04 LTS

Its the time of the year again to upgrade Ubuntu version in WSL/WSL2 since the Ubuntu 20.04 LTS came out last week.

Please follow along the following steps in your WSL console to upgrade to the new version:

  • Check installed Ubuntu version

    Take a note of your current Ubuntu version by running the following command:

    lsb_release -a
    
    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 18.04.4 LTS
    Release:        18.04
    Codename:       bionic
    

    **Upgrading to 20.04 should work seamlessly when upgrading from 18.04. However if you are on older versions then the suggested path should be upgrading first to 18.04 from 16.04 for example.

  • Upgrade installed packages

    sudo apt update
    sudo apt list --upgradable
    sudo apt upgrade
    
  • Remove unused packages

    sudo apt --purge autoremove
    
  • Install update-manager-core package if not already installed

    sudo apt install update-manager-core
    
  • Upgrade to 20.04

    sudo do-release-upgrade
    

    If you receive the following message:

    Checking for a new Ubuntu release
    There is no development version of an LTS available.
    To upgrade to the latest non-LTS develoment release 
    set Prompt=normal in /etc/update-manager/release-upgrades.
    

    Then do an upgrade forcefully using the following command:

    sudo do-release-upgrade -d
    
  • Finally check the version after upgrade is done:

    lsb_release -a
    

    and you should receive the following similar output:

    No LSB modules are available.
    Distributor ID: Ubuntu
    Description:    Ubuntu 20.04 LTS
    Release:        20.04
    Codename:       focal