This post first appeared in a series of posts on my personal blog.
There are two primary ways to try Ubuntu Focal Fossa, the codename for the release which will become Ubuntu 20.04 LTS (long term support). You can make a copy of your existing installation and upgrade it or you can download and side-load a fresh image from Canonical’s daily builds. Both methods need testing and we welcome feedback on, see: How to report a bug related to Ubuntu on WSL.
Upgrade an existing installation
We do not want to upgrade your existing working Ubuntu 16.04 or 18.04 installation at this time, not while testing. We will make a backup of your working installation, import it under a new name, and then upgrade it to Focal Fossa. This will give you the ability to switch back and forth between your working Ubuntu installation and your upgraded Focal image.
Open Command Prompt and run the following to find your WSL distro:
wsl.exe --list --all --verbose
You can see above we have Ubuntu installed as our WSL distro and and it is running on WSL 2. Don’t worry if you do not have WSL 2 yet.
Export our working installation of Ubuntu installation as a backup:
wsl.exe --export Ubuntu ubuntu-backup.tar.gz
Import our working installation of Ubuntu as our test installation:
wsl.exe --import UbuntuFocal C:\UbuntuFocal ubuntu-backup.tar.gz
If you have WSL2 enabled, instead run:
wsl.exe --import UbuntuFocal C:\UbuntuFocal ubuntu-backup.tar.gz --version 2
Explanation:
wsl.exe --import <name of your new distro> <path to store the file system> <path to tar.gz file>
And on systems with WSL 2 you can add --version 2 to ensure it is imported as WSL 2 if you have not set wsl.exe --set-default-version 2.
If you re-run the following you will see all of your WSL distros:
wsl.exe --list --all --verbose
You can run our test installation as follows:
wsl.exe -d UbuntuFocal -u <username>
Method 1: Edit /etc/apt/sources.list with nano
We upgrade this Ubuntu distro to Focal by editing /etc/apt/sources.list with nano:
$ sudo nano /etc/apt/sources.list
We want to replace all instances of ‘bionic’ with ‘focal’ so press Control [Ctrl] and backslash \ []
At “Search (to replace)” type: bionic
At “Replace with” type: focal
At “Replace this instance?” type: A
Then all instances of bionic in the text should be converted to focal:
Exit nano with Control + X then Y:
Method 2: sed
In lieu of nano you can also use the UNIX sed tool to search and replace strings within files:
$ sudo sed -i 's/bionic/focal/g' /etc/apt/sources.list
Upgrading After Methods 1 and 2
Now that sources.list is updated, we update apt to fetch the latest package listings from the focal repository:
$ sudo apt update
Then we upgrade installed packages:
$ sudo apt upgrade -y
This will take some time and is likely where some errors may occur.
Method 3: do-release-upgrade
You can use the do-release-upgrade tool:
$ sudo do-release-upgrade -d
Confirmation
To confirm the upgrade took place:
$ sudo cat /etc/os-release
When you run your working installation of Ubuntu you can switch into your test installation of Ubuntu with:
$ wsl.exe -d UbuntuFocal -u hayden
Sideload a fresh build
We will download a daily build of rootfs from the Ubuntu server and import it.
This will give you the ability to switch back and forth between your working installation and Focal.
It will not bring over any of your existing applications or dotfiles. It is a fresh start.
Open Command Prompt and run the following to see your existing WSL distro:
wsl.exe --list --all --verbose
You can see above we have Ubuntu installed as our WSL distro and and it is running on WSL 2.
Run your existing WSL distro:
ubuntu.exe
Change to a download folder on Windows (your username will vary):
$ cd /mnt/c/Users/Hayden/Downloads
Then use wget on WSL to download our rootfs tar file from the Ubuntu cloud image server:
$ wget https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64-wsl.rootfs.tar.gz
Note: If you are on arm64, use: https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-arm64-wsl.rootfs.tar.gz
Exit your WSL environment and return to the Command Prompt:
$ exit
Then import your new file into WSL:
On WSL1:
wsl.exe --import UbuntuFocal C:\UbuntuFocal Downloads\ focal-server-cloudimg-amd64-wsl.rootfs.tar.gz
On WSL2:
wsl.exe --import UbuntuFocal C:\UbuntuFocal Downloads\ focal-server-cloudimg-amd64-wsl.rootfs.tar.gz --version 2
Explanation:
wsl.exe --import
And on systems with WSL 2 you can add --version 2 to ensure it is imported as WSL 2 if you have not set wsl.exe --set-default-version 2.
Then verify by running again:
wsl.exe --list --all --verbose
Boot the new image:
wsl.exe -d UbuntuFocal
This will drop you in as root.
Check we are on Focal:
$ cat /etc/os-release
To create a new default user, use:
$ adduser hayden
To give this user the ability to run sudo, add them to the sudo group:
$ usermod -aG sudo hayden
Finally, exit your Focal WSL distro:
$ exit
And re-enter as your new user:
wsl.exe -d UbuntuFocal -u hayden
This command also runs from your existing Ubuntu install:
You can now:
$ sudo apt update
$ sudo apt upgrade -y
and get the latest packages released in just the last few hours: