From da0bd6271900865a422bf9c4dae5196e00f8b93b Mon Sep 17 00:00:00 2001 From: Dusty Mabe Date: Tue, 8 Aug 2023 23:38:41 -0400 Subject: [PATCH 1/2] overlay.d/05core: drop RHEL8 workarounds for live-generator This should be dead code now. --- .../coreos-liveiso-persist-osmet.service | 2 -- .../modules.d/35coreos-live/live-generator | 34 +------------------ 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-liveiso-persist-osmet.service b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-liveiso-persist-osmet.service index 3cef6adc30..2d50b3315f 100644 --- a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-liveiso-persist-osmet.service +++ b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-liveiso-persist-osmet.service @@ -4,8 +4,6 @@ DefaultDependencies=false ConditionPathExists=/run/ostree-live ConditionKernelCommandLine=coreos.liveiso RequiresMountsFor=/run/media/iso -# on el8, the ISO is mounted by our own systemd unit -After=run-media-iso-mount.service Before=initrd-switch-root.target [Service] diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/live-generator b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/live-generator index dabe2eeb2b..dc761f7b30 100755 --- a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/live-generator +++ b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/live-generator @@ -54,11 +54,6 @@ ExecStartPost=/usr/sbin/ostree-cmdline stop EOF isoroot=$(getarg coreos.liveiso= ||:) -is_rhcos8() { - # Unfortunately we can't rely on /etc/os-release since el8 doesn't seem to - # have https://github.com/dracutdevs/dracut/pull/655. - [[ "${isoroot}" == rhcos-* ]] && [[ $(uname -r) == *.el8* ]] -} if [ -z "${isoroot}" ]; then # In this case, the rootfs is already unpacked into the initrd, or we need @@ -90,32 +85,8 @@ else After=${isosrc_escaped} Requires=${isosrc_escaped} EOF - # Temporary hack for rhel8, where our mount unit can race with udev's - # cdrom_id using open(O_EXCL). See: - # https://github.com/coreos/fedora-coreos-config/pull/1986#pullrequestreview-1120840529 - # https://issues.redhat.com/browse/OCPBUGS-1505 - if is_rhcos8; then - cat >"${UNIT_DIR}/run-media-iso-mount.service" <"${UNIT_DIR}/run-media-iso.mount" <"${UNIT_DIR}/run-media-iso.mount" <"${UNIT_DIR}/sysroot.mount" < Date: Wed, 9 Aug 2023 13:21:09 -0400 Subject: [PATCH 2/2] overlay.d/05core: support booting ISO completely from RAM It has been presented to us a use case where the user wants to actually "install" directly to the same device that was used to boot the live ISO image (i.e. the ISO was written to a block device and then booted from). The way the ISO boots today it mounts the ISO at /run/media/iso and then mounts the CoreOS rootfs from a file under that mountpoint. In this scenario /run/media/iso will be busy and can't be unmounted because the root filesystem of the live running system depends on it. We can adjust the strategy slightly to get a system that runs completely from memory (similar to live PXE systems) by just copying the file out of /run/media/iso and into memory before doing the rootfs mount, which will allow /run/media/iso to be unmounted before the installation commences. This patchset adds a new coreos.liveiso.fromram option to allow requesting this new behavior. We could consider making this new behavior the default, but we'd need to consider the new RAM requirements. For example, before this change on a 2G FCOS system the usage after booting looks like: ``` [core@localhost ~]$ free -m total used free shared buff/cache available Mem: 1953 163 1286 125 503 1519 Swap: 0 0 0 ``` With this change (and the coreos.liveiso.fromram kernel arguemnt specified) the usage looks like: ``` [core@localhost ~]$ free -m total used free shared buff/cache available Mem: 1953 173 688 808 1091 824 Swap: 0 0 0 ``` The usage would scale with the size of the rootfs. i.e. RHCOS is larger so the memory requirements would be larger too. --- .../coreos-liveiso-persist-osmet.service | 4 ++- .../modules.d/35coreos-live/live-generator | 35 +++++++++++++++++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-liveiso-persist-osmet.service b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-liveiso-persist-osmet.service index 2d50b3315f..e4cc6dba27 100644 --- a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-liveiso-persist-osmet.service +++ b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/coreos-liveiso-persist-osmet.service @@ -1,10 +1,12 @@ [Unit] Description=Persist Osmet Files (ISO) -DefaultDependencies=false ConditionPathExists=/run/ostree-live ConditionKernelCommandLine=coreos.liveiso RequiresMountsFor=/run/media/iso Before=initrd-switch-root.target +# DefaultDependencies=true so this unit gets stopped on switchroot to +# allow for /run/media/iso to get unmounted. +DefaultDependencies=true [Service] Type=oneshot diff --git a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/live-generator b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/live-generator index dc761f7b30..add4e6dcca 100755 --- a/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/live-generator +++ b/overlay.d/05core/usr/lib/dracut/modules.d/35coreos-live/live-generator @@ -98,6 +98,9 @@ Wants=systemd-udev-settle.service After=sysinit.target After=initrd-root-device.target Before=initrd-root-fs.target +# This will make /run/media/iso get unmounted when no longer needed, +# which will aid in the coreos.liveiso.fromram case. +StopWhenUnneeded=true [Mount] What=/${isosrc} @@ -106,16 +109,44 @@ Options=ro Type=iso9660 EOF + # Determine what to mount in sysroot.mount based on if we were asked to run + # completely from RAM via coreos.liveiso.fromram karg. + if getargbool 0 coreos.liveiso.fromram; then + sysrootrequiresmountsfor="" + sysrootfsimg=/rootfs.img + # Add service to copy the rootfs.img from the ISO to memory + cat >"${UNIT_DIR}/coreos-liveiso-run-media-iso-cp-rootfsimg.service" <"${UNIT_DIR}/sysroot.mount" <