From e773704e0b985ab313d864dd430f2644018dda7c Mon Sep 17 00:00:00 2001 From: SuperGregM <57850025+SuperGregM@users.noreply.github.com> Date: Sat, 5 Jul 2025 14:47:44 -0700 Subject: [PATCH 1/6] fix for broken rootfs auto-resize - added cloud-guest-utils package --- create-image.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/create-image.sh b/create-image.sh index 30ccb36..c89cd4a 100755 --- a/create-image.sh +++ b/create-image.sh @@ -228,7 +228,10 @@ 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 ..." @@ -242,6 +245,8 @@ 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 From 3abea336efa4d33bf953ab7ed7b55cc4960180f1 Mon Sep 17 00:00:00 2001 From: SuperGregM <57850025+SuperGregM@users.noreply.github.com> Date: Sat, 5 Jul 2025 14:48:13 -0700 Subject: [PATCH 2/6] feat. Add extra cleanup steps to minimize image size --- create-image.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/create-image.sh b/create-image.sh index c89cd4a..a2a9ae3 100755 --- a/create-image.sh +++ b/create-image.sh @@ -250,6 +250,12 @@ 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 From 9b989772ee6a905cc477f41ecc777f8f231b0baa Mon Sep 17 00:00:00 2001 From: SuperGregM <57850025+SuperGregM@users.noreply.github.com> Date: Sat, 5 Jul 2025 14:51:03 -0700 Subject: [PATCH 3/6] feat. add progress bars to Creating VM images & Compressing images --- create-image.sh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/create-image.sh b/create-image.sh index a2a9ae3..a326b22 100755 --- a/create-image.sh +++ b/create-image.sh @@ -274,14 +274,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:" From b6c94144651c410f5edfd1ca2291d7daf507c174 Mon Sep 17 00:00:00 2001 From: SuperGregM <57850025+SuperGregM@users.noreply.github.com> Date: Sat, 5 Jul 2025 14:57:10 -0700 Subject: [PATCH 4/6] fix typos & add newlines for readabillity --- README.md | 14 +++++++------- create-image.sh | 14 ++++++++++---- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 2a5ad37..980a22e 100644 --- a/README.md +++ b/README.md @@ -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) @@ -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 @@ -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 \ @@ -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 \ @@ -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! diff --git a/create-image.sh b/create-image.sh index a326b22..e2fe971 100755 --- a/create-image.sh +++ b/create-image.sh @@ -179,7 +179,8 @@ 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 @@ -190,12 +191,14 @@ 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 + 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-final.service systemctl enable cloud-init-hotplugd.socket + colorecho "$GREEN" "Clearing package cache ..." printf "y\ny\n" | pacman -Scc END @@ -205,8 +208,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 @@ -234,6 +237,7 @@ 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 ..." @@ -241,8 +245,10 @@ 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 From 2057164082a46dd3a44ec25f600c39d23f28d532 Mon Sep 17 00:00:00 2001 From: SuperGregM <57850025+SuperGregM@users.noreply.github.com> Date: Sat, 5 Jul 2025 14:59:01 -0700 Subject: [PATCH 5/6] fix: update template VM from Debian to Ubuntu in README - debian is to old to build on my machine or maybe others?? --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 980a22e..fe857c8 100644 --- a/README.md +++ b/README.md @@ -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 ``` From 1427080f2c01cfb502a6b2cbf2c35114b7a8ee17 Mon Sep 17 00:00:00 2001 From: SuperGregM <57850025+SuperGregM@users.noreply.github.com> Date: Wed, 20 Aug 2025 17:30:09 -0700 Subject: [PATCH 6/6] fix: update cloud-init installation to use archlinux.org package --- create-image.sh | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/create-image.sh b/create-image.sh index e2fe971..7f4022f 100755 --- a/create-image.sh +++ b/create-image.sh @@ -188,16 +188,14 @@ 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