From f70e03fb6d28f16566c40d0982768e5e12aad128 Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Sat, 11 Nov 2023 00:29:03 +0100 Subject: [PATCH 1/4] Fix -V flag Resolves #41 --- alpine-make-vm-image | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/alpine-make-vm-image b/alpine-make-vm-image index 6c962d5..d9b62af 100755 --- a/alpine-make-vm-image +++ b/alpine-make-vm-image @@ -90,7 +90,7 @@ # # -h --help Show this help message and exit. # -# -v --version Print version and exit. +# -V --version Print version and exit. # # APK APK command to use. Default is "apk". # @@ -392,7 +392,7 @@ wgets() ( #============================= M a i n ==============================# -opts=$(getopt -n $PROGNAME -o a:b:B:cCf:hi:k:m:p:Pr:s:S:tv \ +opts=$(getopt -n $PROGNAME -o a:b:B:cCf:hi:k:m:p:Pr:s:S:tV \ -l arch:,boot-mode:,branch:,fs-skel-chown:,fs-skel-dir:,image-format:,image-size:,initfs-features:,kernel-flavor:,keys-dir:,mirror-uri:,no-cleanup,packages:,partition,repositories-file:,rootfs:,script-chroot,serial-console,help,version \ -- "$@") || help 1 >&2 From 2f3f8522b0ee58e68372d0d7eb401580750120e5 Mon Sep 17 00:00:00 2001 From: Petr Man Date: Sat, 6 Jan 2024 15:15:27 +0100 Subject: [PATCH 2/4] Fix boot with LTS kernel by running mkinitfs after kernel installation Resolves #23 --- alpine-make-vm-image | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/alpine-make-vm-image b/alpine-make-vm-image index d9b62af..3d9a85b 100755 --- a/alpine-make-vm-image +++ b/alpine-make-vm-image @@ -604,12 +604,6 @@ fsprogs_pkgs= prepare_chroot . -#----------------------------------------------------------------------- -einfo "Installing and configuring mkinitfs" - -_apk add --root . mkinitfs -setup_mkinitfs . "base $ROOTFS $INITFS_FEATURES" - #----------------------------------------------------------------------- einfo "Installing kernel linux-$KERNEL_FLAVOR" @@ -620,6 +614,12 @@ else _apk add --root . linux-$KERNEL_FLAVOR linux-firmware-none fi +#----------------------------------------------------------------------- +einfo "Installing and configuring mkinitfs" + +_apk add --root . mkinitfs +setup_mkinitfs . "base $ROOTFS $INITFS_FEATURES" + #----------------------------------------------------------------------- if [ "$BOOT_MODE" = 'BIOS' ]; then einfo 'Setting up extlinux bootloader' From 585791d9f95acc63c6bf9c4bf75d0f41e146f1cc Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Sat, 6 Jan 2024 19:02:36 +0100 Subject: [PATCH 3/4] Readme: Rewrite instructions for aarch64 regarding older Alpine --- README.adoc | 50 ++++++++++++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/README.adoc b/README.adoc index ba00ba2..614ea14 100644 --- a/README.adoc +++ b/README.adoc @@ -8,12 +8,10 @@ ifdef::env-github[] image:https://github.com/{gh-name}/workflows/CI/badge.svg["Build Status", link="https://github.com/{gh-name}/actions"] endif::env-github[] -This project provides a script for making customized https://alpinelinux.org/[Alpine Linux] disk images for x86_64 and aarch64 virtual machines. +This project provides a script for making customized https://alpinelinux.org/[Alpine Linux] disk images for x86_64 and aarch64 footnote:[Supported since Alpine Linux v3.19. See <>.] virtual machines. You can choose between BIOS mode (using https://syslinux.org/[Syslinux], only for x86_64) and UEFI mode (using Linux https://docs.kernel.org/admin-guide/efi-stub.html[EFI stub]). It’s quite simple (400 LoC of shell), fast (~32 seconds on GitHub Actions), requires minimum dependencies (QEMU and filesystem tools). -IMPORTANT: aarch64 currently only works with the kernel (linux-virt or linux-lts) from Alpine edge! See <> for more information and a workaround. - TIP: Don’t need VM, just wanna chroot into Alpine Linux? Try https://github.com/alpinelinux/alpine-chroot-install[alpine-chroot-install]! Or do you want to create a custom rootfs? @@ -51,29 +49,6 @@ Or, if you are on Alpine Linux, you can simply install the https://pkgs.alpineli == Howtos -[[aarch64-v3.18]] -=== Create Alpine v3.18 (latest-stable) image for aarch64 - -The Linux kernel (_linux-virt_, _linux-lts_ or _linux-edge_ package) in Alpine v3.18 and earlier doesn’t have https://cateee.net/lkddb/web-lkddb/EFI_ZBOOT.html[EFI_ZBOOT] enabled, so EFI stub cannot load a compressed vmlinuz. -We backported it to v3.18, but then we had to revert it due to a problem with Grub (see https://gitlab.alpinelinux.org/alpine/aports/-/issues/15263[alpine/aports#15263]). - -If you want to build an image with a stable branch of Alpine Linux, you can, but you must install the kernel from the edge branch. -This is relatively safe because the kernel package doesn’t have any dynamic dependencies and the version in v3.18 and edge will be in sync at least until v3.19 is released. - -. Create a `repositories` file with a pinned main repository from edge, e.g.: -+ -[source] ----- -@edge https://dl-cdn.alpinelinux.org/alpine/edge/main -https://dl-cdn.alpinelinux.org/alpine/v3.18/main -https://dl-cdn.alpinelinux.org/alpine/v3.18/community ----- - -. Run {script-name} with the options `--repositories-file ./repositories` and `--packages linux-virt@edge` (or `linux-lts@edge` if you use `--kernel-flavor lts`). - -This will first install _linux-virt_ from v3.18, but in the later step it will reinstall it from the edge branch. - - === Create images for aarch64 on x86_64 host All you need to do is install the https://www.qemu.org/docs/master/user/main.html[QEMU User space emulator] for aarch64 and register it in https://docs.kernel.org/admin-guide/binfmt-misc.html[binfmt_misc] as the interpreter for aarch64 binaries. @@ -110,6 +85,29 @@ See link:.github/workflows/ci.yml[] for a complete example. After that, run {script-name} with the option `--arch aarch64`. +[[aarch64-old]] +=== Create aarch64 image with Alpine v3.18 or older + +The Linux kernel (_linux-virt_, _linux-lts_ or _linux-edge_ package) in Alpine v3.18 and earlier doesn’t have https://cateee.net/lkddb/web-lkddb/EFI_ZBOOT.html[EFI_ZBOOT] enabled, so EFI stub cannot load a compressed vmlinuz. +We backported it to v3.18, but then we had to revert it due to a problem with Grub (see https://gitlab.alpinelinux.org/alpine/aports/-/issues/15263[alpine/aports#15263]). + +If you want to build an image with an older branch of Alpine Linux, you can, but you must install the kernel from the v3.19 branch (or newer). +This is relatively safe because the kernel package doesn’t have any dynamic dependencies. + +. Create a `repositories` file with a pinned main repository from v3.19, e.g.: ++ +[source] +---- +@v319 https://dl-cdn.alpinelinux.org/alpine/v3.19/main +https://dl-cdn.alpinelinux.org/alpine/v3.18/main +https://dl-cdn.alpinelinux.org/alpine/v3.18/community +---- + +. Run {script-name} with the options `--repositories-file ./repositories` and `--packages linux-virt@v319` (or `linux-lts@v319` if you use `--kernel-flavor lts`). + +This will first install _linux-virt_ from v3.18, but in the later step it will reinstall it from the v3.19 branch. + + === Create image for VMware (ESXi) VMware and disk images (virtual disks) is one big mess. From 04c2e6df9628b675c82e5f0444315fdec459c6ea Mon Sep 17 00:00:00 2001 From: Jakub Jirutka Date: Sat, 6 Jan 2024 19:07:50 +0100 Subject: [PATCH 4/4] Release version 0.13.0 --- README.adoc | 4 ++-- alpine-make-vm-image | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.adoc b/README.adoc index 614ea14..330b748 100644 --- a/README.adoc +++ b/README.adoc @@ -1,8 +1,8 @@ = Make Alpine Linux VM Image :script-name: alpine-make-vm-image -:script-sha1: 75aafcb883155bcaad9ad0dadb3e22e082152c1e +:script-sha1: 0fe2deca927bc91eb8ab32584574eee72a23d033 :gh-name: alpinelinux/{script-name} -:version: 0.12.0 +:version: 0.13.0 ifdef::env-github[] image:https://github.com/{gh-name}/workflows/CI/badge.svg["Build Status", link="https://github.com/{gh-name}/actions"] diff --git a/alpine-make-vm-image b/alpine-make-vm-image index 3d9a85b..341a656 100755 --- a/alpine-make-vm-image +++ b/alpine-make-vm-image @@ -115,7 +115,7 @@ set -eu PATH="$PATH:/usr/sbin:/usr/bin:/sbin:/bin" readonly PROGNAME='alpine-make-vm-image' -readonly VERSION='0.12.0' +readonly VERSION='0.13.0' readonly VIRTUAL_PKG=".make-$PROGNAME" # An opaque string used to detect changes in resolv.conf. readonly RESOLVCONF_MARK="### created by $PROGNAME ###"