How to make a custom ISO image with mkimage

From Alpine Linux
Revision as of 22:39, 31 August 2017 by Okeuday (talk | contribs)
Jump to: navigation, search

This document explains how to build a custom ISO image using the new mkimage scripts located in aports directory.


First make sure we have the needed tools

apk add alpine-sdk build-base apk-tools alpine-conf busybox fakeroot syslinux xorriso

For efi you shoud add

mtools dosfstools grub-efi

Create a user (e.g. build) and add it to abuild group:

adduser build -G abuild

Then create signing keys (-i installs them in /etc/apk/keys which is required for later)

abuild-keygen -i -a

{{Tip| Make sure your public keys are placed in /etc/apk/keys/ (example:

ls /etc/apk/keys/

Clone (or update) the git repository.

git clone git://

Make sure the apk index is up to date (so apk finds the packages):

apk update


The mkimg scripts are shipped with pre-configured profiles.

The format is mkimg.$

So, in order to have a custom ISO, you should create your own mkimg.$ script.

This is an example used to have ZFS module, overlayfs (which allows to have /lib/modules in r/w), a serial console output and some other useful apks to build a simple NAS:

export PROFILENAME=nas
cat << EOF > ~/aports/scripts/mkimg.$
profile_$PROFILENAME() {
        kernel_cmdline="unionfs_size=512M console=tty0 console=ttyS0,115200"
        syslinux_serial="0 115200"
        kernel_addons="zfs spl"
        apks="\$apks iscsi-scst zfs-scripts zfs zfs-utils-py
                cciss_vol_status lvm2 mdadm mkinitfs mtools nfs-utils
                parted rsync sfdisk syslinux unrar util-linux xfsprogs
                dosfstools ntfs-3g
        local _k _a
        for _k in \$kernel_flavors; do
                apks="\$apks linux-\$_k"
                for _a in \$kernel_addons; do
                        apks="\$apks \$_a-\$_k"
        apks="\$apks linux-firmware"

Set the script as executable:

chmod +x mkimg.$

Create the ISO

Create a iso directory in your home dir:

mkdir -p ~/iso

Then create the actual ISO. In this example we will use the edge version x86_64:

sh --tag edge \ --outdir ~/iso \ --arch x86_64 \ --repository \ --profile $PROFILENAME


Of course, several passages of this doc can be automated with a script, like the repository/arch/outdir settings. This steps are left to you and to your imagination :)

Testing your ISO image

Qemu is useful for a quick test of your created ISO image.