Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
live: mount ISO squashfs directly out of the rootfs image
cosa now uses identical initramfs and rootfs images in the PXE and ISO
artifacts.  Instead of expecting /root.squashfs, find the rootfs image
in the ISO pxeboot directory and mount the squashfs from a fixed offset
in the cpio archive.  Use the existence of the coreos.liveiso= karg,
rather than a flag file, to detect that we're ISO-booted.  In ISO mode,
use bsdtar to read the osmet files out of the rootfs image.
  • Loading branch information
bgilbert committed Aug 8, 2020
1 parent 8f482cf commit 18a2c51
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
@@ -0,0 +1,15 @@
[Unit]
Description=Persist osmet files (ISO)
DefaultDependencies=false
ConditionPathExists=/run/ostree-live
ConditionKernelCommandLine=coreos.liveiso
RequiresMountsFor=/run/media/iso
Before=initrd-switch-root.target

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/mkdir -p /run/coreos-installer/osmet
# bsdtar reads cpio archives, and unlike cpio(1L), knows how to seek over
# members it isn't reading
ExecStart=/usr/bin/bsdtar -x -C /run/coreos-installer/osmet -f /run/media/iso/images/pxeboot/rootfs.img *.osmet
@@ -1,9 +1,11 @@
[Unit]
Description=Persist osmet files
Description=Persist osmet files (PXE)
DefaultDependencies=false
ConditionPathExists=/run/ostree-live
ConditionKernelCommandLine=!coreos.liveiso
# Downloads and unpacks the osmet files if not already appended
After=coreos-livepxe-rootfs.service
Before=initrd-switch-root.target

[Service]
Type=oneshot
Expand Down
Expand Up @@ -3,7 +3,7 @@ Description=Acquire live PXE rootfs image
DefaultDependencies=false
ConditionPathExists=/usr/lib/initrd-release
ConditionPathExists=/run/ostree-live
ConditionPathExists=/etc/coreos-live-want-rootfs
ConditionKernelCommandLine=!coreos.liveiso

After=basic.target
# Network is enabled here
Expand Down
19 changes: 9 additions & 10 deletions overlay.d/05core/usr/lib/dracut/modules.d/20live/live-generator
Expand Up @@ -52,9 +52,10 @@ ExecStartPre=/usr/sbin/ostree-cmdline start
ExecStartPost=/usr/sbin/ostree-cmdline stop
EOF

# In this case, the rootfs is already unpacked into the initrd, or we need
# to retrieve it
if [ -f /etc/coreos-live-want-rootfs ]; then
isoroot=$(getarg coreos.liveiso= ||:)
if [ -z "${isoroot}" ]; then
# In this case, the rootfs is already unpacked into the initrd, or we need
# to retrieve it
cat >"${UNIT_DIR}/sysroot.mount" <<EOF
# Automatically generated by live-generator
Expand All @@ -70,12 +71,6 @@ Where=/sysroot
Type=squashfs
EOF
else
isoroot=$(getarg coreos.liveiso=)
if [ -z "${isoroot}" ]; then
echo "Missing required coreos.liveiso kernel argument" 1>&2
exit 1
fi

# And in this case, it's on the ISO
mkdir -p /run/media/iso
isosrc=dev/disk/by-label/${isoroot}
Expand Down Expand Up @@ -113,9 +108,13 @@ Before=initrd-root-fs.target
RequiresMountsFor=/run/media/iso
[Mount]
What=/run/media/iso/root.squashfs
What=/run/media/iso/images/pxeboot/rootfs.img
Where=/sysroot
Type=squashfs
# Offset of the squashfs within the rootfs cpio. Assumes newc format
# and that a file named "root.squashfs" is the first member. This offset
# is checked by coreos-assembler cmd-buildextend-live at build time.
Options=offset=124
EOF
fi

Expand Down
Expand Up @@ -41,7 +41,10 @@ install() {
install_and_enable_unit "coreos-live-clear-sssd-cache.service" \
"ignition-complete.target"

install_and_enable_unit "coreos-live-persist-osmet.service" \
install_and_enable_unit "coreos-liveiso-persist-osmet.service" \
"default.target"

install_and_enable_unit "coreos-livepxe-persist-osmet.service" \
"default.target"

inst_simple "$moddir/coreos-liveiso-reconfigure-nm-wait-online.service" \
Expand Down

0 comments on commit 18a2c51

Please sign in to comment.