Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save mslinn/50a3a8d26cbab51c634ed8e2edf129ae to your computer and use it in GitHub Desktop.

Select an option

Save mslinn/50a3a8d26cbab51c634ed8e2edf129ae to your computer and use it in GitHub Desktop.
Upgrade to Ubuntu 20.04 Focal on WSL1 and WSL2
  1. Display whether you have WSL1 or WSL2 by typing wsl --list --verbose into a PowerShell prompt, like this:
    PS C:\Users\mslin> wsl --list --verbose
      NAME      STATE           VERSION
    * Ubuntu    Running         1
    
    The above shows that a machine has WSL1 installed.
  2. Ignore this step if you have WSL2.

    The default Ubuntu sleep command does not work on WSL1. sleep must work properly in order for the upgrade to succeed. To fix the problem, replace /bin/sleep with an equivalent Python 3 program prior to running do-release-upgrade. This will avoid the problem sleep: cannot read realtime clock: Invalid argument described in this askubuntu posting. To do this, type:
    $ sudo mv /bin/sleep{,-}  # renames sleep to sleep-
    $ sudo vi /bin/sleep     # I use vi, but you can use any editor with sudo
    Enter the code for /bin/sleep shown below using your favorite editor:
    #!/usr/bin/env python3
    
    import sys
    import time
    
    time.sleep(int(sys.argv[1]))
    Save the file. Now make your replacement for sleep executable:
    $ sudo chmod a+x /bin/sleep
  3. Ensure that all previous upgrades have been applied:
    $ sudo apt upgrade
  4. Verify that the last line of /etc/update-manager/release-upgrades is Prompt=normal. If not, edit with your favorite editor:
    $ sudo vi /etc/update-manager/release-upgrades
  5. Run the upgrade. Because Ubuntu rolls out its upgrade to users gradually, you might have to try this several times over a few days. Some of my machines update earlier than others, even though they are in the same building. You may find instructions elsewhere that advocate "Force direct upgrade by using the -d switch". This is incorrect. There is no such thing as a direct upgrade, instead the -d switch installs a development version, which means you will forever after install a whole lot of prerelease software. Don't do that unless you have a good reason. This is what most users should type:
    $ sudo do-release-upgrade
  6. The installation will die after a while with the following error:
    dpkg: error processing package libc6:amd64 (--configure):
    installed libc6:amd64 package post-installation script subprocess returned error exit status 1
    Errors were encountered while processing:
    libc6:amd64
    
    To fix the problem (from https://stackoverflow.com/a/61697214/553865) edit /var/lib/dpkg/info/libc6\:amd64.postinst and comment out this line near the top of the file:
    set -e
    
    so it looks like this:
    # set -e
    
    Now type:
    $ apt-get -f install
  7. To conclude the upgrade, type:
    $ sudo apt upgrade --fix-missing
    $ sudo apt upgrade
    $ sudo apt-get dist-upgrade -y
    $ sudo apt autoremove
    $ sudo apt autoclean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment