Testing modified install images and packages
Overview
Modifying packages that are part of the install diskless boot (e.g. on install media), or the parameters that can be accepted by the boot process, is a little more involved than modifying individual packages, especially for netboot images. This author discovered that then when working on feat: answerfile kernel cmdline parameter (#26) · Issues · alpine / mkinitfs · GitLab an issue he opened to request / offer to develop an improvement to unattended installation by adding the option of applying a setup-alpine 'answerfile' automatically via netboot, by providing a URL to a new answerfile kernel commandline parameter.
The easy part
- Update the list of options accepted by the installer using the kernel command line by modifying mkinitfs
initramfs-init.inand updating themanpage inmkinitfs-bootparam.7.in. - Install the new
mkinitfsinto one's build environment usingmake installinmkinitfs. - Build a new image using
scripts/mkimage.shfrom aports with the appropriate parameters. - You now have an image that will accept your new parameter.
Challenge #1
- In the case of
answerfilean additional change needs to be make to thefirstbootinitscript, which is part of theopenrcpackage. - That means building a new
openrcpackage and getting it into the generated image. - To do that one has to point
scripts/mkimage.shat the package repository created when building the modifiedopenrcpackage. - This is sufficient for images where all the packages used during boot and install are present on the install media.
Challenge #2 (netboot)
- For netboot, however, the process is more involved because the
openrcpackage has to be downloaded from an external repository during the boot process. - This would seem easy; one might think you one could just supply put the
packagesdirectory created during theopenrcbuild on a web server and using thealpine_repo=<URI_of_repo>, but the problem is thatalpine_repoonly accepts a single repository. - In addition the package list must be signed by a key which appears in the image (that part is easy using the
mkimage.shparameters). - This means one must have include all the packages netboot and install will require in the new repository.
- There is one more gotcha; One must include all the dependencies for the packages in the repository or the packages will fail to install.
One method of creating the necessary signed repository
Identify all the base packages needed by netboot
- In the
mkinitfsrepository issuegrep pkgs initfamfs-init.inand make note of all the packages that may be used by the initramfs. - In
aports,grep apks scripts/*. This will identify all base packages added by themkimage.shscript. - You also need
linux-lts linux-virt wireless-regdb scanelf alpine-conf alpine-base openssl
Identify all the dependencies of the base packages
Create a file with the list of base packages on a single line, separated by spaces. For example a file named
~/base-packages.lstcontaining:package1 package2 package3
Install the package
lua-aportsFrom a package directory in a package from
aports, issue the following command:ap recursive-deps $(cat ~/base-packages.lst) >~/base-deps.lst
Build all required packages
Create required list of package directories in aports
Take the list of base packages and dependencies above and create a single file with all packages on a single line, separated by spaces. For
~/base-deps.lstabove you could do:cat ~/base-deps.lst ~/base-pkgs.lst | tr $'\n' ' ' >~/oneline-deps.lst
From a package directory in a package from
aports, issue the following command:ap builddirs $(cat ~/oneline-deps.lst) >~/packages-to-build.lst
Create a directory for the package repository
<code class="fenced-code-block language-shell">mkdir -p ~/packages/main</code>
Add this directory to the system APK repositories
NOTE: This will break things if you are not running latest (edge) Alpine in your build environment
Assuming your user home dir is
/home/user, then to the file/etc/apk/repositoriesadd/home/user/packages/main
Build the packages
cd ~ for pdir in $(cat ~/packages-to-build.lst); do (cd $pdir && abuild -r -m | tee -a ~/build.log); done
Build a netboot image
From the aports directory:
./scripts/mkimage.sh --profile netboot --repository /home/user/packages/main
Copy to your netboot server and netboot
See Netboot Alpine Linux using iPXE and adjust paths as necessary.