Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ Arch Linux for ARM (Aarch64) on Lima
![Platform: ARM64](https://img.shields.io/badge/platform-ARM64-0091BD?logo=arm&logoColor=white)
![Apple Silicon](https://img.shields.io/badge/Apple-Silicon-green.svg)

[![GitHub release](https://img.shields.io/github/v/release/mschirrmeister/archlinux-lima.svg?style=flat)](https://github.com/mschirrmeister/archlinux-lima/releases)
![Build](https://github.com/mschirrmeister/archlinux-lima/actions/workflows/build_image_cloud.yaml/badge.svg) [![Issues](https://img.shields.io/github/issues/mschirrmeister/archlinux-lima.svg)](https://github.com/mschirrmeister/archlinux-lima/issues)
[![GitHub release](https://img.shields.io/github/v/release/mschirrmeister/archlinux-lima.svg?style=flat)](https://github.com/mschirrmeister/archlinux-lima/releases)
![Build](https://github.com/mschirrmeister/archlinux-lima/actions/workflows/build_image_cloud.yaml/badge.svg) [![Issues](https://img.shields.io/github/issues/mschirrmeister/archlinux-lima.svg)](https://github.com/mschirrmeister/archlinux-lima/issues)
[![PRs](https://img.shields.io/github/issues-pr/mschirrmeister/archlinux-lima.svg)](https://github.com/mschirrmeister/archlinux-lima/pulls)

[![Contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/mschirrmeister/archlinux-lima/issues)
Expand Down Expand Up @@ -70,7 +70,7 @@ If you want to build an image yourself, clone the repo and build it locally.
1. Build the image with a Lima VM

```shell
limactl start --name build-arch template://debian
limactl start --name build-arch template://ubuntu
limactl shell build-arch
```

Expand All @@ -84,7 +84,7 @@ If you want to build an image yourself, clone the repo and build it locally.
3. Back on your Mac generate a Lima template

```shell
./create-archlinux-yaml.sh
./create-archlinux-template.sh
```

4. Start the VM
Expand Down Expand Up @@ -133,7 +133,7 @@ After the template is created you can start the VM with:

## 🛠️ Customize qcow2 image

In case you want to create a customized image you can start a local VM via **qemu**, do all you changes and use the updated **qcow2** image in a new template.
In case you want to create a customized image you can start a local VM via **qemu**, do all you changes and use the updated **qcow2** image in a new template.
On a Mac with Apple Silicon (only tested on M4) you can boot a VM with the following command.

qemu-system-aarch64 \
Expand All @@ -144,7 +144,7 @@ On a Mac with Apple Silicon (only tested on M4) you can boot a VM with the follo
-m 2048 \
-rtc base=utc \
-drive if=pflash,format=raw,file="/opt/homebrew/share/qemu/edk2-aarch64-code.fd",readonly=on \
-drive if=pflash,format=raw,file=edk2-arm-vars.fd \
-drive if=pflash,format=raw,file="/opt/homebrew/share/qemu/edk2-arm-vars.fd" \
-drive file="Arch-Linux-aarch64-cloudimg-20250510.0.qcow2",if=virtio,format=qcow2 \
-boot menu=on \
-nic user,id=NAT,model=virtio-net-pci,mac=02:00:00:00:00:01 \
Expand Down Expand Up @@ -297,14 +297,14 @@ And big love to all the upstream maintainers, contributors, and every open sourc

## 🤝 Pull Up & Contribute

Ayo, this project’s open for all!
Ayo, this project’s open for all!
If you got ideas, fixes, or just wanna chop it up about Arch on Apple Silicon, you in the right spot.

- **Pull Requests:** Got code? Drop a PR, keep it clean, and let’s build together.
- **Issues:** Something broke? Got a question? Throw it in the issues—no dumb questions here.
- **Discussions:** Wanna vibe about setups, Lima tricks, or just flex your config? Start a thread, let’s get it.

New to open source? Don’t trip—every contribution counts, and I got your back if you need help with your first PR.
New to open source? Don’t trip—every contribution counts, and I got your back if you need help with your first PR.
Let’s make this repo legendary, together!


Expand Down
49 changes: 32 additions & 17 deletions create-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,23 +179,24 @@ colorecho "$GREEN" "Refresh package database..."
pacman -Sy --noconfirm

colorecho "$GREEN" "Installing latest linux-aarch64 kernel..."
pacman -Sy linux-aarch64 --needed --noconfirm --nodeps --nodeps
pacman -Sy linux-aarch64 --needed --noconfirm --nodeps

colorecho "$GREEN" "Removing linux-firmware ..."
pacman -Rdd linux-firmware linux-firmware-whence --noconfirm

colorecho "$GREEN" "Running full system upgrade ..."
pacman -Syu --noconfirm

colorecho "$GREEN" "Installing cloud-init ..."
curl -LO --output-dir /tmp/ https://gist.githubusercontent.com/mschirrmeister/a009b8ce91a20bcc214c66f62aced9c9/raw/8c66f4d9bfb3ea05828f37ce420680eb007191de/cloud-init-23.1.2-2-any.pkg.tar.xz
pacman -U /tmp/cloud-init-23.1.2-2-any.pkg.tar.xz --noconfirm
rm -f /tmp/cloud-init-23.1.2-2-any.pkg.tar.xz
cloudinit_pkg="cloud-init-25.1.2-1-any.pkg.tar.zst"
curl -LO --output-dir /tmp/ "https://archive.archlinux.org/packages/c/cloud-init/$cloudinit_pkg"
pacman -U /tmp/"$cloudinit_pkg" --needed --noconfirm
rm -f /tmp/"$cloudinit_pkg"

colorecho "$GREEN" "Enabling cloud-init services ..."
systemctl enable cloud-init-local.service
systemctl enable cloud-init.service
systemctl enable cloud-config.service
systemctl enable cloud-init-main.service
systemctl enable cloud-final.service
systemctl enable cloud-init-hotplugd.socket

colorecho "$GREEN" "Clearing package cache ..."
printf "y\ny\n" | pacman -Scc
END
Expand All @@ -205,8 +206,8 @@ colorecho "$GREEN" "Copying boot partition files ..."
sudo cp -r /mnt/arch-root/boot/* /mnt/arch-boot/
sudo rm -rf /mnt/arch-root/boot/*

# --- GRUB Install ---
colorecho "$GREEN" "Installing GRUB bootloader ..."
# --- Setting up boot partition ---
colorecho "$GREEN" "Mounting boot partition ..."
sudo mkdir -p /mnt/arch-root/boot
sudo mount $BOOTP /mnt/arch-root/boot

Expand All @@ -228,23 +229,37 @@ colorecho "$GREEN" "Installing GRUB bootloader ..."
pacman-key --init
pacman-key --populate archlinuxarm
pacman -Sy grub efibootmgr --noconfirm
colorecho "$GREEN" "Clearing package cache ..."

colorecho "$GREEN" "Installing cloud-guest-utils for rootfs auto-resize ..."
pacman -Sy cloud-guest-utils --needed --noconfirm

colorecho "$GREEN" "Append the following cmdline to grub: "
sed -i "s/^GRUB_CMDLINE_LINUX_DEFAULT=\".*\"/GRUB_CMDLINE_LINUX_DEFAULT=\"console=ttyAMA0\"/" /etc/default/grub

colorecho "$GREEN" "Installing GRUB ..."
grub-install --target=arm64-efi --efi-directory=/boot --removable
colorecho "$GREEN" "Generating GRUB config ..."
grub-mkconfig -o /boot/grub/grub.cfg

colorecho "$GREEN" "Updating mirrors..."
sed -i 's/^# Server/Server/' /etc/pacman.d/mirrorlist.save
colorecho "$GREEN" "Installing pacman-contrib..."

colorecho "$GREEN" "Installing pacman-contrib..."
pacman -S pacman-contrib --needed --noconfirm

colorecho "$GREEN" "Ranking mirrors..."
rankmirrors -n 5 /etc/pacman.d/mirrorlist.save | grep -v '^\s*#' | tee /etc/pacman.d/mirrorlist

colorecho "$GREEN" "Clearing package cache ..."
printf "y\ny\n" | pacman -Scc
END

# --- Zero out free space in root partition to improve compressibility ---
colorecho "$GREEN" "Zeroing out free space in root partition ..."
sudo dd if=/dev/zero of=/mnt/arch-root/zero.fill bs=1M status=progress || true
sudo sync
sudo rm -f /mnt/arch-root/zero.fill

# --- Unmount boot if still mounted ---
if mountpoint -q /mnt/arch-root/boot; then
sudo umount /mnt/arch-root/boot || sudo umount -l /mnt/arch-root/boot
Expand All @@ -263,14 +278,14 @@ QCOW2_IMG="${IMAGE_NAME%.img}.qcow2"
VMDK_IMG="${IMAGE_NAME%.img}.vmdk"

colorecho "$GREEN" "Creating VM images ..."
sudo qemu-img convert -O qcow2 "$RAW_IMG" "$QCOW2_IMG"
sudo qemu-img convert -O vmdk "$RAW_IMG" "$VMDK_IMG"
sudo qemu-img convert -p -O qcow2 "$RAW_IMG" "$QCOW2_IMG"
sudo qemu-img convert -p -O vmdk "$RAW_IMG" "$VMDK_IMG"

if [ "$COMPRESS" = 1 ]; then
colorecho "$GREEN" "Compressing images ..."
sudo xz -T 0 "$RAW_IMG"
sudo xz -T 0 "$QCOW2_IMG"
sudo xz -T 0 "$VMDK_IMG"
sudo xz -T 0 --verbose "$RAW_IMG"
sudo xz -T 0 --verbose "$QCOW2_IMG"
sudo xz -T 0 --verbose "$VMDK_IMG"
fi

colorecho "$GREEN" "All images created:"
Expand Down