Skip to content

feat(templates): add amazonlinux-2023 distro#4454

Open
electricalgorithm wants to merge 1 commit intolima-vm:masterfrom
electricalgorithm:feat/add-al2023-template
Open

feat(templates): add amazonlinux-2023 distro#4454
electricalgorithm wants to merge 1 commit intolima-vm:masterfrom
electricalgorithm:feat/add-al2023-template

Conversation

@electricalgorithm
Copy link
Copy Markdown

@electricalgorithm electricalgorithm commented Dec 14, 2025

This commit adds a simple template for the Amazon Linux 2023 operating system's latest version. The OS is scheduled to release every two weeks, therefore, we need to find a way to automatically update it from the following AWS website:

@electricalgorithm
Copy link
Copy Markdown
Author

electricalgorithm commented Dec 14, 2025

Testing it with:

$ LIMA_TEMPLATES_PATH=lima/templates limactl start --name al2023-test --arch aarch64 --cpus 4 template:amazonlinux-2023 --debug

Correct os-release Info:

[gokhankocmarli@lima-al2023-test ~]$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.9.20251208"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
VENDOR_NAME="AWS"
VENDOR_URL="https://aws.amazon.com/"
SUPPORT_END="2029-06-30"

Correct uname:

[gokhankocmarli@lima-al2023-test ~]$ uname -a
Linux lima-al2023-test 6.1.158-180.294.amzn2023.aarch64 #1 SMP Mon Dec  1 05:36:18 UTC 2025 aarch64 aarch64 aarch64 GNU/Linux

Correct repos:

[gokhankocmarli@lima-al2023-test ~]$ yum repolist
repo id                                                                         repo name
amazonlinux                                                                     Amazon Linux 2023 repository
kernel-livepatch                                                                Amazon Linux 2023 Kernel Livepatch repository

@electricalgorithm
Copy link
Copy Markdown
Author

electricalgorithm commented Dec 14, 2025

It's weird, but the only problem is that the backspace does not work. I don't know if Lima uses SSH underneath, but I'll investigate the debug logs by re-shelling to the VM.

[Update] Yep, it looks like it uses SSH.

DEBU[0000] Failed to detect CPU features. Assuming that AES acceleration is available on this Apple silicon.
DEBU[0000] OpenSSH version 10.0.2 detected, is GSSAPI supported: true
DEBU[0000] AES accelerator seems available, prioritizing aes128-gcm@openssh.com and aes256-gcm@openssh.com
DEBU[0000] executing ssh (may take a long)): [/usr/bin/ssh -F /dev/null -o IdentityFile="/Users/gokhankocmarli/.lima/_config/user" -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o NoHostAuthenticationForLocalhost=yes -o PreferredAuthentications=publickey -o Compression=no -o BatchMode=yes -o IdentitiesOnly=yes -o GSSAPIAuthentication=no -o Ciphers="^aes128-gcm@openssh.com,aes256-gcm@openssh.com" -o User=gokhankocmarli -o ControlMaster=auto -o ControlPath="/Users/gokhankocmarli/.lima/al2023-test/ssh.sock" -o ControlPersist=yes -t -o SendEnv=COLORTERM -o LogLevel=ERROR -p 54658 127.0.0.1 -- cd /Users/gokhankocmarli/ || cd /Users/gokhankocmarli ; exec "$SHELL" --login]

Then I believe it could be an issue with SendEnv.

[Update 2] The --preserve-env did not work either. Plus, I realised that the mountpoint did not work. I believe there has to be a directory called /Users/gokhankocmarli, which is my $HOME on the host machine.

@electricalgorithm electricalgorithm changed the title feat(templates): add AL2023 2025-12-08's image feat(templates): add AL2023 2025-12-08's image [WIP - do-not-merge] Dec 14, 2025
@afbjorklund
Copy link
Copy Markdown
Member

Previous attempt with this (Amazon Linux) was:

I think it also failed to automate the updating?

@electricalgorithm
Copy link
Copy Markdown
Author

Previous attempt with this (Amazon Linux) was:

* [Create amazonlinux2023 template #2537](https://github.com/lima-vm/lima/pull/2537)

I think it also failed to automate the updating?

Thank you for the info! I have reviewed the comments there and see that two concerns are in common:

  • No dynamic approach to retrieve the latest image from CDN. (Should we even want this?)
  • Mount problems with virtiofs.

I'll spend some time fixing those. However, I believe that we can move this template to experimental ones and start iteratively on fixing stuff. Some folks may not need mounts or be happy with just having AL2023 with Lima without the latest image since it's possible to easily update the system using dnf upgrade --releasever=<new-release-date>. Or even better, use latest for releasever.

We could easily patch it by adding a run-script when the image is initialised and upgrading the system to the latest. Wdyt?

@afbjorklund
Copy link
Copy Markdown
Member

You can "fix" the mount problems by excluding the methods that don't work, like 9p (check other templates for examples)

But it's a problem if there is no download URL. Maybe something that upstream can provide, if you ask them?

@electricalgorithm
Copy link
Copy Markdown
Author

You can "fix" the mount problems by excluding the methods that don't work, like 9p (check other templates for examples)

I used the same mount point restrictions as the previous PR, the issue still exists but I'm investigating it.

But it's a problem if there is no download URL. Maybe something that upstream can provide, if you ask them?

I added a new update-template script under hack/ directory. This script automatically fetches the latest version and updates the template. I used the trick of following the URL endpoint /latest and parsing its 302 response to resolve the latest version number (including .1/.0 at the end). I don't know who calls them in what frequency, but I see that it's the common and agreed approach.

@electricalgorithm electricalgorithm force-pushed the feat/add-al2023-template branch 2 times, most recently from 9dba5e5 to 897084e Compare December 14, 2025 18:33
@electricalgorithm electricalgorithm changed the title feat(templates): add AL2023 2025-12-08's image [WIP - do-not-merge] feat(templates): add AL2023 2025-12-08's image Dec 14, 2025
@electricalgorithm electricalgorithm changed the title feat(templates): add AL2023 2025-12-08's image feat(templates): add amazonlinux-2023 distro Dec 14, 2025
@electricalgorithm
Copy link
Copy Markdown
Author

Update: The mount problem is gone, and it's possible to update the image to the latest one within a new script under hack/. Additionally, the system tries to update the latest release when the machine is initialised automatically.

I'll check the unit test and the lining stuff later. Does it look OK to you?

Comment thread templates/experimental/amazonlinux-2023.yaml Outdated
Comment thread templates/amazonlinux-2023.yaml Outdated
Comment thread templates/amazonlinux-2023.yaml Outdated
Comment thread templates/experimental/amazonlinux-2023.yaml Outdated
Comment thread hack/update-template-amazonlinux-2023.sh Outdated
Comment thread templates/amazonlinux-2023.yaml
Comment thread hack/update-template-amazonlinux-2023.sh Outdated
Comment thread hack/update-template-amazonlinux-2023.sh Outdated
Comment thread templates/amazonlinux-2023.yaml Outdated
Comment thread templates/experimental/amazonlinux-2023.yaml Outdated
@AkihiroSuda AkihiroSuda added this to the v2.1.0 (?) milestone Dec 15, 2025
@AkihiroSuda AkihiroSuda linked an issue Dec 15, 2025 that may be closed by this pull request
@electricalgorithm electricalgorithm force-pushed the feat/add-al2023-template branch 2 times, most recently from b48521f to dedcd61 Compare December 15, 2025 16:04
@electricalgorithm
Copy link
Copy Markdown
Author

Could someone possibly help me reproduce these CI checks? I do run shellcheck, shfmt, etc. but I guess there's some configurations different since all seems good on my local. There has to be a guide on running/replicating GitHub actions in this doc: https://lima-vm.io/docs/dev/testing/

@afbjorklund
Copy link
Copy Markdown
Member

There is make lint, but keeping it in sync with .github is a constant battle... Maybe https://github.com/nektos/act

@afbjorklund
Copy link
Copy Markdown
Member

I still don't want new commits to Lima every two (just to bump a snapshot version) every two weeks


# Workaround for Amazon Linux 2023
if [ -f /etc/os-release ] && grep -q "Amazon Linux" /etc/os-release; then
# 1. Create missing mount.virtiofs helper
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to just fix this issue in the Amazon Linux upstream?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why this issue happens specifically with Amazon Linux. I thought it was very similar to Fedora?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can cut a ticket to the team, but I think it should not be the concern of this PR. We can go with the current upstream approach, and when the fix is there, remove the patch here.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should not be the concern of this PR

Why not.

Comment thread templates/_images/amazonlinux-2023.yaml Outdated
@AkihiroSuda
Copy link
Copy Markdown
Member

ping @electricalgorithm

@electricalgorithm
Copy link
Copy Markdown
Author

I'll update the PR as soon as possible.

@AkihiroSuda AkihiroSuda removed this from the v2.1.0 milestone Mar 12, 2026
@electricalgorithm electricalgorithm force-pushed the feat/add-al2023-template branch 3 times, most recently from f18c355 to 4564989 Compare April 12, 2026 22:08
@electricalgorithm
Copy link
Copy Markdown
Author

I still don't want new commits to Lima every two (just to bump a snapshot version) every two weeks.

It should not be. We can update it on every two weeks by the hack script, but in the end provision script will handle it for us automatically.

@electricalgorithm
Copy link
Copy Markdown
Author

Hey people,

Sorry for being late. Quite busy months in Winter, as you can imagine. I updated the PR with a change to the latest image and addressed your comments. Please review the code once more, although it does not have much changes.

There seems to be issue on GitHub's CI checks. The Lints job failed due to a README's link issue which the PR does not have any modification. I believe there's another issue there. On the vz's integation test job, I couldn't understand if that was my changes breaking it, but after discussing with GitHub's Copilot, looks like it is regarding to setup of the job.

Can you verify that the failures are not related to the PR? If all looks good, please check the version string in the template -- which is 1.2.1 right now and check if it's possible to merge it until the release window closes.

Kindest regards,
Gyokhan

cc: @afbjorklund @AkihiroSuda

@AkihiroSuda AkihiroSuda added this to the v2.1.2 milestone Apr 12, 2026
Comment thread templates/amazonlinux.yaml
Comment thread pkg/cidata/cidata.TEMPLATE.d/boot.Linux/04-amazonlinux-virtiofs.sh Outdated
Comment thread pkg/cidata/cidata.TEMPLATE.d/boot.Linux/04-amazonlinux-virtiofs.sh Outdated
This commit adds a simple template for the Amazon Linux 2023 operating
system's 2026-04-06 version. The OS is scheduled to release every two weeks,
therefore, a new script called hack/update-template-amazonlinux.sh
is added next to the other template updater scripts.

Find the latest images here:
https://cdn.amazonlinux.com/al2023/os-images/latest/

This patch:
- Adds amazonlinux-2023 template with 2026-04-06 release.
- Resolves mount issues on AL2023 with host OS.
release.
- Adds update-template-amazonlinux.sh script to help maintainers
automatically update the verison.

Signed-off-by: Gyokhan Kochmarla <hello@gyokhan.com>
@electricalgorithm electricalgorithm force-pushed the feat/add-al2023-template branch from 4564989 to 2c60121 Compare April 12, 2026 23:33
@electricalgorithm
Copy link
Copy Markdown
Author

Please review again :) I updated the code to apply your suggestions.

@electricalgorithm
Copy link
Copy Markdown
Author

Looks like the failure in jobs is due to the flakiness. Not related to the change.

# Amazon Linux 2023 requires a workaround for virtiofs mounts.
# The mount.virtiofs helper script is missing, and cloud-init
# may fail to mount the filesystems. This creates the helper
# and manually mounts them.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it still produce the valid /etc/fstab? If so, just running mount -a might be fine here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I start a new AL2023 KVM to check and it seems that the fstab does not have the virtiofs configs. Therefore, mount -a does not work and we need to parse them from cloud init config's user-data. That was a nice catch by the way. I'm not super into OSes, thanks for the advice!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why doesn't it generate fstab?

/var/log/cloud-init.log:

2026-04-16 07:52:01,442 - util.py[DEBUG]: Cloud-init v. 22.2.2 running 'init-local' at Thu, 16 Apr 2026 07:52:01 +0000. Up 1.95 seconds.
[...]
2026-04-16 07:52:04,763 - cc_mounts.py[DEBUG]: mounts configuration is [['lima-648190f135cc8172', '/Users/suda', 'virtiofs', 'ro,nofail', '0', '0']]
2026-04-16 07:52:04,763 - util.py[DEBUG]: Reading from /etc/fstab (quiet=False)
2026-04-16 07:52:04,763 - util.py[DEBUG]: Read 217 bytes from /etc/fstab
2026-04-16 07:52:04,764 - cc_mounts.py[DEBUG]: Attempting to determine the real name of lima-648190f135cc8172
2026-04-16 07:52:04,764 - cc_mounts.py[DEBUG]: changed lima-648190f135cc8172 => None
2026-04-16 07:52:04,764 - cc_mounts.py[DEBUG]: Ignoring nonexistent named mount lima-648190f135cc8172
2026-04-16 07:52:04,764 - cc_mounts.py[DEBUG]: Attempting to determine the real name of ephemeral0
2026-04-16 07:52:04,764 - cc_mounts.py[DEBUG]: changed default device ephemeral0 => None
2026-04-16 07:52:04,764 - cc_mounts.py[DEBUG]: Ignoring nonexistent default named mount ephemeral0
2026-04-16 07:52:04,764 - cc_mounts.py[DEBUG]: Attempting to determine the real name of swap
2026-04-16 07:52:04,764 - cc_mounts.py[DEBUG]: changed default device swap => None
2026-04-16 07:52:04,764 - cc_mounts.py[DEBUG]: Ignoring nonexistent default named mount swap
2026-04-16 07:52:04,764 - cc_mounts.py[DEBUG]: Skipping nonexistent device named None
2026-04-16 07:52:04,764 - cc_mounts.py[DEBUG]: no need to setup swap
2026-04-16 07:52:04,764 - cc_mounts.py[DEBUG]: No modifications to fstab needed
2026-04-16 07:52:04,764 - handlers.py[DEBUG]: finish: init-network/config-mounts: SUCCESS: config-mounts ran successfully

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe related to "AL2023 contains a customized version of cloud-init."

https://docs.aws.amazon.com/linux/al2023/ug/cloud-init.html

@electricalgorithm
Copy link
Copy Markdown
Author

Can you re-run the GitHub jobs and merge it if looks good to you since all conversations are resolved @AkihiroSuda?

@AkihiroSuda AkihiroSuda requested a review from a team April 15, 2026 10:22
USER_DATA="/var/lib/cloud/instance/user-data.txt"
if [ -f "${USER_DATA}" ]; then
# Parse all mount entries from user-data (mount0, mount1, ...)
MOUNT_ENTRIES=$(grep -E '^\s*-\s+\[mount[0-9]+,' "${USER_DATA}" || true)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This grep didn't work for me

[root@lima-amazonlinux ~]# head  /var/lib/cloud/instance/user-data.txt
#cloud-config
# vim:syntax=yaml

growpart:
  mode: auto
  devices: ['/']
mounts:
- [lima-648190f135cc8172, /Users/suda, virtiofs, "ro,nofail", "0", "0"]
timezone: Asia/Tokyo

[root@lima-amazonlinux ~]# grep -E '^\s*-\s+\[mount[0-9]+,' /var/lib/cloud/instance/user-data.txt

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@electricalgorithm

How did you test your PR?
In what condition user-data can have mounts named mount0, mount1, etc.?


# Workaround for Amazon Linux 2023
if [ -f /etc/os-release ] && grep -q "Amazon Linux" /etc/os-release; then
# 1. Create missing mount.virtiofs helper
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this helper needed in the first place when we have to execute the mount command by ourselves?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The helper doesn't even seem to exist on other distros, such as almalinux-9

@AkihiroSuda AkihiroSuda removed this from the v2.1.2 milestone Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add amazon linux template

3 participants