Amazon Linux 2023 on WSL2
This post is an update to Amazon Linux 2022 on WSL2 after container images of AL2023 were made available on the Amazon Linux CDN.
Like almost any Linux distribution that has a container image available, you can run Amazon Linux 2023 on the Windows Subsystem for Linux. This guide assumes you've installed and configured WSL2 and already have something like Debian running under it.
AL2023 container images can be downloaded from: https://cdn.amazonlinux.com/al2023/os-images/latest/container/
WSL will be able to import the
.tar.xz file directly.
From PowerShell or Command Line, import the image into WSL (you may want to choose a different
InstallLocation than I have here):
wsl --import AL2023 C:\WSL\AL2023 Downloads\al2023-container-<version>-x86_64.tar.xz
Assuming that succeeded you can log in (as root):
wsl --distribution AL2023
Processing fstab with mount -a failed.
[root@Lenovo-M90n andrew]# cat /etc/os-release
PRETTY_NAME="Amazon Linux 2023"
Install Missing Packages
Now even though we used the
container image and not
container-minimal, a lot of the things you'd find in an AL2023 AMI are missing. That's why
Processing fstab with mount -a failed. It's meant to be a container runtime image, not a user-interactive image, so this is normally fine.
dnf -y install util-linux passwd sudo
That will get you
sudo, which are all you need for the remaining steps.
system-default-editor which will default to
nano. I'm old enough to prefer
vim, and if you add
vim-default-editor to the
dnf install command it will skip
If you want an unprivileged user, you'll need to add one and set a password (the
--groups wheel option makes it so this user can use
--user-group --groups wheel \
--comment User \
To configure WSL to use that user by default, you also need to create an
/etc/wsl.conf file with the following content:
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 AL2023
# Wait 8 seconds?
wsl --distribution AL2023
To get it to show up under Windows Terminal you might need to stop WSL or reboot:
I've also needed to delete the
state.json file from
%LOCALAPPDATA%\Packages\Microsoft.WindowsTerminal_8wekyb3d8bbwe\LocalState\ to get the icon shortcuts for the Windows Terminal to update, but that's probably a bug.
If you've got WSLg installed you can even install a GUI application and run it from AL2023. Since it doesn't have many GUI applications, you could install and run one from Flathub:
sudo dnf -y install flatpak
flatpak install -y --user --from https://dl.flathub.org/repo/appstream/org.gnome.TwentyFortyEight.flatpakref
flatpak run --user org.gnome.TwentyFortyEight