Skip to content

Conversation

pothos
Copy link
Member

@pothos pothos commented Sep 12, 2025

The growth of binaries over time and the inclusion of new features
filled the available boot partition space, so that the kernel+initrd
almost couldn't fit twice anymore as required for updates. We employed
workarounds such as wrapper scripts for ignition, afterburn and other
binaries so that they are loaded from /usr. However, this was still not
enough and we would have to do the same for (network) kernel modules and
firmware. To avoid making this ever more complex we can use a dedicated
initrd focused on loading the full initrd from /usr and then this full
initrd can use dracut as before and even drop all the workarounds we
accumulated.

Introduce a busybox init script that prepares a minimal environment,
has debug toggles and an emergency shell, and only loads the real initrd
from /usr to switch over to it. Because mdev is not a proper udev
replacement, some additional scripting is needed. Busybox's modprobe
can't work with dependencies well and we need the real kmod for that
(which is also good to guarantee have the same modprobe options set).
Also, some other busybox commands are often lacking things such as
loading a kernel module automatically and this has to be done
explicitly. We still set up dm-verity for /usr so that we have the same
security properties (The code comes from the bootengine systemd
generators we have and also covers the PXE boot with a squashfs /usr
passed from an additional cpio). The real initrd then reuses the mount
point for /usr, and loads any kernel modules and firmware that wasn't
loaded already.
We also have to make the dependencies for parse-ip-for-networkd.service
a bit more explicit because the removal of the /sysusr mount in the full
initrd exposed a race condition.

How to use

With flatcar/scripts#3241

Testing done

See above

pothos added a commit to flatcar/scripts that referenced this pull request Sep 12, 2025
Pulls in flatcar/bootengine#110

Co-authored-by: James Le Cuirot <[email protected]>
Signed-off-by: Kai Lueke <[email protected]>
@pothos pothos force-pushed the kai/initrd-in-usr branch 2 times, most recently from 0316d71 to 6794e4b Compare September 15, 2025 14:23
pothos added a commit to flatcar/scripts that referenced this pull request Sep 15, 2025
Pulls in flatcar/bootengine#110

Co-authored-by: James Le Cuirot <[email protected]>
Signed-off-by: Kai Lueke <[email protected]>
@pothos pothos force-pushed the kai/initrd-in-usr branch 5 times, most recently from 0dc77a3 to 4dd3627 Compare September 15, 2025 15:13
pothos added a commit to flatcar/scripts that referenced this pull request Sep 15, 2025
Pulls in flatcar/bootengine#110

Co-authored-by: James Le Cuirot <[email protected]>
Signed-off-by: Kai Lueke <[email protected]>
@pothos pothos force-pushed the kai/initrd-in-usr branch 2 times, most recently from e42505c to e8672f8 Compare September 15, 2025 16:23
pothos added a commit to flatcar/scripts that referenced this pull request Sep 15, 2025
Pulls in flatcar/bootengine#110

Co-authored-by: James Le Cuirot <[email protected]>
Signed-off-by: Kai Lueke <[email protected]>
pothos added a commit to flatcar/scripts that referenced this pull request Sep 16, 2025
Pulls in flatcar/bootengine#110

Co-authored-by: James Le Cuirot <[email protected]>
Signed-off-by: Kai Lueke <[email protected]>
@pothos pothos force-pushed the kai/initrd-in-usr branch 2 times, most recently from 3172cf1 to 91da72b Compare September 16, 2025 14:30
pothos added a commit to flatcar/scripts that referenced this pull request Sep 17, 2025
Pulls in flatcar/bootengine#110

Co-authored-by: James Le Cuirot <[email protected]>
Signed-off-by: Kai Lueke <[email protected]>
pothos added a commit to flatcar/scripts that referenced this pull request Sep 17, 2025
Pulls in flatcar/bootengine#110

Co-authored-by: James Le Cuirot <[email protected]>
Signed-off-by: Kai Lueke <[email protected]>
pothos added a commit to flatcar/scripts that referenced this pull request Sep 18, 2025
Pulls in flatcar/bootengine#110

Co-authored-by: James Le Cuirot <[email protected]>
Signed-off-by: Kai Lueke <[email protected]>
pothos added a commit to flatcar/scripts that referenced this pull request Sep 18, 2025
Pulls in flatcar/bootengine#110

Co-authored-by: James Le Cuirot <[email protected]>
Signed-off-by: Kai Lueke <[email protected]>
@pothos pothos changed the title test: initrd in /usr Use a minimal initrd to switch to the full initrd stored in /usr Sep 19, 2025
@pothos pothos marked this pull request as ready for review September 19, 2025 08:26
@pothos pothos requested a review from a team as a code owner September 19, 2025 08:26
pothos added a commit to flatcar/scripts that referenced this pull request Sep 19, 2025
The growth of binaries over time and the inclusion of new features
filled the available boot partition space, so that the kernel+initrd
almost couldn't fit twice anymore as required for updates. We employed
workarounds such as wrapper scripts for ignition, afterburn and other
binaries so that they are loaded from /usr. However, this was still not
enough and we would have to do the same for (network) kernel modules and
firmware. To avoid making this ever more complex we can use a dedicated
initrd focused on loading the full initrd from /usr and then this full
initrd can use dracut as before and even drop all the workarounds we
accumulated.

Generate a minimal initrd to use instead of the full bootengine initrd.
The bootengine initrd gets stored as squashfs on /usr. The minimal
initrd still includes the early_cpio for amd64 microcode updates.
We have a fixed list of modules or module directories to include, only
focused on loading /usr and any emergency console interaction. This
requires also checking for module dependencies to copy over.
The busybox, veritysetup, and kmod binaries are needed and get their
required libraries resolved and copied over. They are not static and
use shared libraries which should be ok for now. The resulting vmlinuz
file is 27 MB for amd64, down from ~60 MB, so we have enough room to
include more kernel modules and so on for the next years while we also
grow the boot partition and wait for users to redeploy until we can rely
on a larger boot partition and eventually drop the minimal initrd again.

Pulls in flatcar/bootengine#110 for the
minimal initrd script and flatcar/seismograph#12
for making the device mapper discovery for the "rootdev" command more
reliable.

This also requied a backport of a kernel patch from 2017 that exposes
the PARTUUID in the /sys uevent file.

Co-authored-by: James Le Cuirot <[email protected]>
Signed-off-by: Kai Lueke <[email protected]>
pothos added a commit to flatcar/scripts that referenced this pull request Sep 19, 2025
The growth of binaries over time and the inclusion of new features
filled the available boot partition space, so that the kernel+initrd
almost couldn't fit twice anymore as required for updates. We employed
workarounds such as wrapper scripts for ignition, afterburn and other
binaries so that they are loaded from /usr. However, this was still not
enough and we would have to do the same for (network) kernel modules and
firmware. To avoid making this ever more complex we can use a dedicated
initrd focused on loading the full initrd from /usr and then this full
initrd can use dracut as before and even drop all the workarounds we
accumulated.

Generate a minimal initrd to use instead of the full bootengine initrd.
The bootengine initrd gets stored as squashfs on /usr. The minimal
initrd still includes the early_cpio for amd64 microcode updates.
We have a fixed list of modules or module directories to include, only
focused on loading /usr and any emergency console interaction. This
requires also checking for module dependencies to copy over.
The busybox, veritysetup, and kmod binaries are needed and get their
required libraries resolved and copied over. They are not static and
use shared libraries which should be ok for now. The resulting vmlinuz
file is 27 MB for amd64, down from ~60 MB, so we have enough room to
include more kernel modules and so on for the next years while we also
grow the boot partition and wait for users to redeploy until we can rely
on a larger boot partition and eventually drop the minimal initrd again.

Pulls in flatcar/bootengine#110 for the
minimal initrd script and flatcar/seismograph#12
for making the device mapper discovery for the "rootdev" command more
reliable.

This also requied a backport of a kernel patch from 2017 that exposes
the PARTUUID in the /sys uevent file.

Co-authored-by: James Le Cuirot <[email protected]>
Signed-off-by: Kai Lueke <[email protected]>
The growth of binaries over time and the inclusion of new features
filled the available boot partition space, so that the kernel+initrd
almost couldn't fit twice anymore as required for updates. We employed
workarounds such as wrapper scripts for ignition, afterburn and other
binaries so that they are loaded from /usr. However, this was still not
enough and we would have to do the same for (network) kernel modules and
firmware. To avoid making this ever more complex we can use a dedicated
initrd focused on loading the full initrd from /usr and then this full
initrd can use dracut as before and even drop all the workarounds we
accumulated.

Introduce a busybox init script that prepares a minimal environment,
has debug toggles and an emergency shell, and only loads the real initrd
from /usr to switch over to it. Because mdev is not a proper udev
replacement, some additional scripting is needed. Busybox's modprobe
can't work with dependencies well and we need the real kmod for that
(which is also good to guarantee have the same modprobe options set).
Also, some other busybox commands are often lacking things such as
loading a kernel module automatically and this has to be done
explicitly. We still set up dm-verity for /usr so that we have the same
security properties (The code comes from the bootengine systemd
generators we have and also covers the PXE boot with a squashfs /usr
passed from an additional cpio). The real initrd then reuses the mount
point for /usr, and loads any kernel modules and firmware that wasn't
loaded already.
We also have to make the dependencies for parse-ip-for-networkd.service
a bit more explicit because the removal of the /sysusr mount in the full
initrd exposed a race condition.

Signed-off-by: Kai Lueke <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant