https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&user=Squish42&feedformat=atomAlpine Linux - User contributions [en]2024-03-29T09:38:11ZUser contributionsMediaWiki 1.40.0https://wiki.alpinelinux.org/w/index.php?title=How_to_make_a_custom_ISO_image_with_mkimage&diff=15663How to make a custom ISO image with mkimage2019-01-10T11:37:47Z<p>Squish42: /* Prerequisite */</p>
<hr />
<div>This document explains how to build a custom ISO image using the new mkimage scripts located in [[aports]] directory.<br />
<br />
== Prerequisite ==<br />
<br />
First make sure we have the needed tools<br />
{{Cmd|apk add alpine-sdk build-base apk-tools alpine-conf busybox fakeroot syslinux xorriso squashfs-tools}}<br />
For efi you should add<br />
{{Cmd|mtools dosfstools grub-efi}}<br />
<br />
Create a user (e.g. build) and add it to abuild group:<br />
{{Cmd|adduser build -G abuild}}<br />
<br />
Then create signing keys (-i installs them in /etc/apk/keys which is required for later)<br />
{{Cmd|abuild-keygen -i -a}}<br />
<br />
{{Tip| Make sure your public keys are placed in /etc/apk/keys/ (example: build-xxxxxxxx.rsa.pub)}}<br />
{{Cmd|ls /etc/apk/keys/}}<br />
<br />
Clone (or update) the [http://git.alpinelinux.org/cgit/aports/ git repository].<br />
{{Cmd|git clone git://git.alpinelinux.org/aports}}<br />
<br />
<br />
Make sure the apk index is up to date (so apk finds the packages):<br />
{{Cmd|apk update}}<br />
<br />
== Configuration ==<br />
<br />
The mkimg scripts are shipped with pre-configured profiles.<br />
<br />
The format is '''mkimg.$PROFILENAME.sh'''<br />
<br />
So, in order to have a custom ISO, you should create your own '''mkimg.$PROFILENAME.sh''' script.<br />
<br />
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:<br />
<br />
<pre>export PROFILENAME=nas</pre><br />
<br />
<pre><br />
cat << EOF > ~/aports/scripts/mkimg.$PROFILENAME.sh<br />
profile_$PROFILENAME() {<br />
profile_standard<br />
kernel_cmdline="unionfs_size=512M console=tty0 console=ttyS0,115200"<br />
syslinux_serial="0 115200"<br />
kernel_addons="zfs spl"<br />
apks="\$apks iscsi-scst zfs-scripts zfs zfs-utils-py<br />
cciss_vol_status lvm2 mdadm mkinitfs mtools nfs-utils<br />
parted rsync sfdisk syslinux unrar util-linux xfsprogs<br />
dosfstools ntfs-3g<br />
"<br />
local _k _a<br />
for _k in \$kernel_flavors; do<br />
apks="\$apks linux-\$_k"<br />
for _a in \$kernel_addons; do<br />
apks="\$apks \$_a-\$_k"<br />
done<br />
done<br />
apks="\$apks linux-firmware"<br />
}<br />
EOF<br />
</pre><br />
<br />
Set the script as executable:<br />
{{Cmd|chmod +x mkimg.$PROFILENAME.sh}}<br />
<br />
== Create the ISO ==<br />
<br />
{{Cmd|mkimage.sh [--tag RELEASE] [--outdir OUTDIR] [--workdir WORKDIR]<br />
[--arch ARCH] [--profile PROFILE] [--hostkeys] [--simulate]<br />
[--repository REPO] [--extra-repository REPO] [--yaml FILE]<br />
mkimage.sh --help<br />
<br />
options:<br />
--arch Specify which architecture images to build<br />
(default: x86_64)<br />
--hostkeys Copy system apk signing keys to created images<br />
--outdir Specify directory for the created images<br />
--profile Specify which profiles to build<br />
--repository Package repository to use for the image create<br />
--extra-repository Add repository to search packages from<br />
--simulate Don't execute commands<br />
--tag Build images for tag RELEASE<br />
--workdir Specify temporary working directory (cache)<br />
--yaml<br />
<br />
known profiles: ali rpi uboot base minirootfs standard vanilla extended virt xen}}<br />
<br />
Create a iso directory in your home dir:<br />
<br />
{{Cmd|mkdir -p ~/iso}}<br />
<br />
Then create the actual ISO.<br />
In this example we will use the edge version x86_64:<br />
{{Cmd|sh mkimage.sh --tag edge \<br />
--outdir ~/iso \<br />
--arch x86_64 \<br />
--repository http://dl-cdn.alpinelinux.org/alpine/edge/main \<br />
--profile $PROFILENAME<br />
}}<br />
<br />
<br />
'''Notes:'''<br />
<br />
Of course, several passages of this doc can be automated with a script, like the repository/arch/outdir settings.<br />
This steps are left to you and to your imagination :)<br />
<br />
== Testing your ISO image ==<br />
<br />
[[Qemu#Live_mode| Qemu]] is useful for a quick test of your created ISO image.<br />
<br />
[[Category:Package Manager]]<br />
[[Category:ISO]]</div>Squish42