I want to create a custom Alpine Linux image. I want to take the Virtual ISO version (https://dl-cdn.alpinelinux.org/alpine/v3.20/releases/x86_64/alpine-virt-3.20.1-x86_64.iso) extend it with some packages and do some configuration stuff. Then I want to "repack" the achieved state in a new ISO, which then can be used for another VM, for example in vSphere.
I want to enable community repo, install the open-vm-tools package, add to automatic service start (so it gets booted on startup) and enable the network adapter. Basically what I would be doing when executing "setup-alpine". Manually executed, this all works fine. The problem starts when I want to create a new iso out of the current start.
If I understand correctly, what I want to achieve can be done with: mkimage (short documentation on how to use it: https://wiki.alpinelinux.org/wiki/How_to_make_a_custom_ISO_image_with_mkimage).
Sometimes I end up with a created iso, sometimes I don't. When the process resulted with an iso, most of the time they were relatively big ~900MB. The origin is only ~60MB. But none of them are working. When creating a new VM with that iso (e. g. in vSphere) it ends with criticial error: OS not found, etc. I guess I am doing something wrong when it comes to the creation of the mkimg.custom-alpine.sh and the corresponding genapkovl file.
What did I do
- Creation of a local VM with the Virtual Alpine iso
- After startup --> "setup-alpine" + reboot
- Activation of community repos in /etc/apk/repositories
- apk upgrade && apk update
- apk add open-vm-tools
- rc-update add open-vm-tools boot
- after reboot, everything works as desired
- starting the mkimage tutorial
- installing all packages, adding user and permissions, creating key, checking out aports, and so on
Then the script part starts. Setting
export PROFILENAME=custom-alpine
My mkimg.custom-alpine.sh looks like this
#!/bin/sh
profile_custom_alpine() {
profile_standard
kernel_cmdline="unionfs_size=512M console=tty0 console=ttyS0,115200"
syslinux_serial="0 115200"
kernel_addons="zfs"
apks="$apks alpine-base open-vm-tools"
local _k _a
for _k in $kernel_flavors; do
apks="$apks linux-$_k"
for _a in $kernel_addons; do
apks="$apks $_a-$_k"
done
done
apks="$apks linux-firmware"
apkovl="aports/scripts/genapkovl-custom-alpine.sh"
}
For the genapkovl file I used the genapkovl-dhcp.sh as suggested and just added the information for open-vm-tools at the relevant parts.
Then I am creating the actual iso like described with:
sh aports/scripts/mkimage.sh --tag edge \
--outdir ~/iso \
--arch x86_64 \
--repository https://dl-cdn.alpinelinux.org/alpine/edge/main \
--profile $PROFILENAME
Sometimes it works, sometimes it doesn't. But it never resulted in a "working" ISO. So I am assuming I am doing something wrong or I misunderstood something.
Any help?