Amazon Linux 2022 on WSL2
Like almost any Linux distribution that has a container image available, you can run Amazon Linux 2022 on the Windows Subsystem for Linux. This guide assumes you've installed and configured WSL2 and already have something like Debian running under it.
Download
Until AL2022 is available at https://cdn.amazonlinux.com/os-images/latest/ (or more likely https://cdn.amazonlinux.com/os-images/2022/) we'll be pulling it from Amazon ECR Public. When it is on the CDN you won't need another Linux and can instead download the archive directly.
I found it convenient to use Skopeo (sudo apt install skopeo
) rather than setup Docker.
This downloads the latest 2022 image from ECR to al2022/
:
skopeo copy docker://public.ecr.aws/amazonlinux/amazonlinux:2022 dir:al2022
Notice the blob hash in the output:
Getting image source signatures
Copying blob 3cef325a7204 done
Copying config 353840340a done
Writing manifest to image destination
Storing signatures
Copy the blob out to somewhere Windows can see it (note that the hash changes when the image is updated):
cp al2022/3cef325a7204* /mnt/c/amazonlinux-2022.tar.gz
Import
From PowerShell or Command Line, import the image into WSL (you may want to choose a different InstallLocation
than I have here):
wsl --import AL2022 'C:\WSL\AL2022' 'C:\amazonlinux-2022.tar.gz'
Assuming that succeeded you can log in (as root):
wsl --distribution AL2022
Configure
If you want an unprivileged user instead, you'll need to add one and set a password (the --groups wheel
option makes it so this user can use sudo
):
useradd --comment User --create-home --user-group --groups wheel user
passwd user
To configure WSL to use that user by default, you also need to create an /etc/wsl.conf
file with the following content:
[user]
default = user
Log out, terminate the VM, and start it again. This time you should be logged in as the user you created earlier:
wsl --terminate AL2022
wsl --distribution AL2022
To get it to show up under Windows Terminal you might need to stop WSL or reboot:
wsl --shutdown
Enjoy
If you've got WSLg installed you can even install a GUI application and run it from AL2022. Since it doesn't have many GUI applications yet, you could install and run one using flatpak
:
sudo dnf install flatpak
flatpak install --user --from https://dl.flathub.org/repo/appstream/org.gnome.TwentyFortyEight.flatpakref
flatpak run --user org.gnome.TwentyFortyEight