[systemd-devel] USB installer for mkosi

Nils Kattenbeck nilskemail at gmail.com
Fri Aug 18 17:44:13 UTC 2023


Hi,

currently I am building a minimalistic Linux image using mkosi which
should be installed on bare-metal hardware.
For the installation I am trying to create a USB-stick installer which
simply installs the resulting image on the hardware.

First and foremost:
Does someone maybe know of an existing tool which generates such a USB
installer?
For now I have found the installer script[1] from Yocto, and FAI
(Fully automatic installation)[2].
I would like to avoid using Yocto and the script seems to also perform
partitioning etc. which I do not need as mkosi already generates a
ready-to-use raw disk image with partitions set up.
FAI on the other hand seems to focus on network installs and prefers
to build its own images instead of using an arbitrary .raw/ISOs.

So I fear that I will have to write my own installer...
I do not require fancy GUI shenanigans; a simple CLI application
prompting for the destination disk should suffice.

Based on my understanding the primary steps are `cp /dev/usb-stick
/dev/target-disk` (or dd for the old fashioned), followed by a `parted
--script --fix /dev/target-disk print` to resolve GPT warnings due to
the header not being at the end when the disk is larger than the USB
stick.
Is it possible to replace the second step with `systemd-parted`.
Especially given that mkosi v15 now uses it for itself, this would
likely be a lot cleaner than invoking parted.

The major problem I am facing with that approach is how do I know
whether I am booting from a USB stick or already from the final disk
drive.
One technique which comes to mind would be to create two images, one
of which will be placed into the mkosi.extra/ directory of the other.
This way I could have one auto-start the install script whereas the
other image would be completely free of that logic.
Am I missing a more obvious way to perform this?

Any help would be greatly appreciated!
Kind regard, Nils

[1] https://github.com/yoctoproject/poky/blob/13734bb520732882a95da7ee6efe1e5b98568acc/meta/recipes-core/initrdscripts/initramfs-module-install-efi_1.0.bb
[2] https://fai-project.org/


More information about the systemd-devel mailing list