mirror of
https://github.com/kairos-io/immucore.git
synced 2025-09-12 13:17:08 +00:00
Rework workflow (#77)
This makes immucore run more in parallel rather than block everything else. We just tell sysroot.mount that eventually it will be mounted and to wait for a bit. This allows us to be more flexible where to run and run in parallel in cases like cdrom in which we may do things but we need the sysroot to be mounted already but not from us. Also adds the initramfs stage directly in immucore and merges all the dracut config into one Dont create sysroot, just add a timeout override so it waits for us Dont block on the service, just make sure to finish before initrd.target Fix mounts from cmdline More proper log Store logs under the /run/immucore dir Store rootfs and initramfs logs separated Do not log the full stages in INFO level Run initramfs stage in immucore directly on boot and cd/netboot Drop systemd requirement from dracut module Signed-off-by: Itxaka itxaka.garcia@spectrocloud.com
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
install_items+=" /etc/hosts "
|
||||
add_dracutmodules+=" network "
|
@@ -1 +1,8 @@
|
||||
add_dracutmodules+=" immucore "
|
||||
hostonly_cmdline="no"
|
||||
hostonly="no"
|
||||
compress="xz"
|
||||
i18n_install_all="yes"
|
||||
show_modules="yes"
|
||||
install_items+=" /etc/hosts "
|
||||
omit_dracutmodules+=" multipath "
|
||||
add_dracutmodules+=" livenet dmsquash-live immucore network "
|
@@ -8,25 +8,19 @@ GENERATOR_DIR="$2"
|
||||
[ -z "$GENERATOR_DIR" ] && exit 1
|
||||
[ -d "$GENERATOR_DIR" ] || mkdir "$GENERATOR_DIR"
|
||||
|
||||
|
||||
## GENERATE SYSROOT
|
||||
cos_img=$(getarg cos-img/filename=)
|
||||
[ -z "${cos_img}" ] && exit 0
|
||||
|
||||
# This is necessary because otherwise systemd-fstab-generator will se the cmdline with the root=LABEL=X stanza and
|
||||
# say, hey this is the ROOT where we need to boot! so it auto creates a sysroot.mount with the content of the value
|
||||
# passed in the cmdline. But because we usually pass the label of the img (COS_ACTIVE) it will create the wrong mount
|
||||
# service and be stuck in there forever.
|
||||
# by generating it ourselves we get the sysroot.mount into the generators.early dir, which tells systemd to not generate it
|
||||
# as it already exists and the rest is history
|
||||
# Add a timeout to the sysroot so it waits a bit for immucore to mount it properly
|
||||
mkdir -p "$GENERATOR_DIR"/sysroot.mount.d
|
||||
{
|
||||
echo "[Unit]"
|
||||
echo "Before=initrd-root-fs.target"
|
||||
echo "DefaultDependencies=no"
|
||||
echo "[Mount]"
|
||||
echo "Where=/sysroot"
|
||||
echo "What=/run/initramfs/cos-state/${cos_img#/}"
|
||||
echo "Options=ro,suid,dev,exec,auto,nouser,async"
|
||||
} > "$GENERATOR_DIR"/sysroot.mount
|
||||
echo "TimeoutSec=300"
|
||||
} > "$GENERATOR_DIR"/sysroot.mount.d/timeout.conf
|
||||
|
||||
## END GENERATE SYSROOT
|
||||
# Make sure initrd-root-fs.target depends on sysroot.mount
|
||||
# This seems to affect mainly ubuntu-22 where initrd-usr-fs depends on sysroot, but it has a broken link to it as sysroot.mount
|
||||
# is generated under the generator.early dir but the link points to the generator dir.
|
||||
# So it makes everything else a bit broken if you insert deps in the middle.
|
||||
# By default other distros seem to do this as it shows on the map page https://man7.org/linux/man-pages/man7/dracut.bootup.7.html
|
||||
if ! [ -L "$GENERATOR_DIR"/initrd-root-fs.target.wants/sysroot.mount ]; then
|
||||
[ -d "$GENERATOR_DIR"/initrd-root-fs.target.wants ] || mkdir -p "$GENERATOR_DIR"/initrd-root-fs.target.wants
|
||||
ln -s ../sysroot.mount "$GENERATOR_DIR"/initrd-root-fs.target.wants/sysroot.mount
|
||||
fi
|
@@ -3,7 +3,7 @@ Description=immucore
|
||||
DefaultDependencies=no
|
||||
After=systemd-udev-settle.service
|
||||
Requires=systemd-udev-settle.service
|
||||
Before=dracut-initqueue.service sysroot.mount
|
||||
Before=initrd-fs.target
|
||||
Conflicts=initrd-switch-root.target
|
||||
|
||||
[Service]
|
||||
|
@@ -1,16 +0,0 @@
|
||||
[Unit]
|
||||
Description=kairos system initramfs setup before switch root
|
||||
DefaultDependencies=no
|
||||
After=initrd-fs.target
|
||||
Requires=initrd-fs.target
|
||||
Before=initrd.target
|
||||
|
||||
[Service]
|
||||
RootDirectory=/sysroot
|
||||
BindPaths=/proc /sys /dev /run /tmp
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
ExecStart=/usr/bin/elemental run-stage initramfs
|
||||
|
||||
[Install]
|
||||
RequiredBy=initrd.target
|
@@ -2,14 +2,12 @@
|
||||
|
||||
# called by dracut
|
||||
check() {
|
||||
require_binaries "$systemdutildir"/systemd || return 1
|
||||
return 255
|
||||
return 0
|
||||
}
|
||||
|
||||
# called by dracut
|
||||
depends() {
|
||||
echo systemd rootfs-block dm fs-lib
|
||||
#tpm2-tss
|
||||
echo rootfs-block dm fs-lib
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -31,13 +29,8 @@ install() {
|
||||
# missing mkfs.xfs xfs_growfs in image?
|
||||
inst_script "${moddir}/generator.sh" "${systemdutildir}/system-generators/immucore-generator"
|
||||
inst_simple "${moddir}/immucore.service" "${systemdsystemunitdir}/immucore.service"
|
||||
mkdir -p "${initdir}/${systemdsystemunitdir}/initrd-fs.target.requires"
|
||||
ln_r "../immucore.service" "${systemdsystemunitdir}/initrd-fs.target.requires/immucore.service"
|
||||
|
||||
# Until this is done on immucore, we need to ship it as part of the dracut module
|
||||
inst_simple "${moddir}/kairos-setup-initramfs.service" "${systemdsystemunitdir}/kairos-setup-initramfs.service"
|
||||
mkdir -p "${initdir}/${systemdsystemunitdir}/initrd.target.requires"
|
||||
ln_r "../kairos-setup-initramfs.service" "${systemdsystemunitdir}/initrd.target.requires/kairos-setup-initramfs.service"
|
||||
ln_r "../immucore.service" "${systemdsystemunitdir}/initrd.target.requires/immucore.service"
|
||||
|
||||
dracut_need_initqueue
|
||||
}
|
@@ -1,5 +0,0 @@
|
||||
hostonly_cmdline="no"
|
||||
hostonly="no"
|
||||
compress="xz"
|
||||
omit_dracutmodules+=" multipath "
|
||||
add_dracutmodules+=" livenet dmsquash-live "
|
Reference in New Issue
Block a user