Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
pothos committed Oct 5, 2023
1 parent 9eaeae2 commit 8801285
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
26 changes: 26 additions & 0 deletions dracut/10diskless-generator/diskless-generator
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,22 @@ add_requires() {
ln -sf "../${name}" "${requires_dir}/${name}"
}

add_wants() {
local name="$1"
local wants_dir="${UNIT_DIR}/initrd-root-fs.target.wants"
mkdir -p "${wants_dir}"
ln -sf "../${name}" "${wants_dir}/${name}"
}

# set to 1 to enable copying /oem from the initrd
copy_oem=0
# check both the new mount.usr and our old usr kernel options
usr=$(cmdline_arg mount.usr "$(cmdline_arg usr)")
root=$(cmdline_arg root)
rootfstype=$(cmdline_arg rootfstype tmpfs)
rootflags=$(cmdline_arg rootflags)
# check possible future systemd support for separate "/var"
var=$(cmdline_arg mount.var)

# If usr= was not specified and a squashfs is bundled in the initrd use it.
if [[ -z "${usr}" && -f /usr.squashfs ]]; then
Expand Down Expand Up @@ -151,3 +160,20 @@ Type=auto
Options=nodev
EOF
fi

if [[ -z "${var}" ]]; then
add_wants sysroot-oem.mount
cat >"${UNIT_DIR}/sysroot-var.mount" <<EOF
# Automatically generated by diskless-generator
[Unit]
ConditionPathExists=/dev/disk/by-label/VAR
Before=initrd-root-fs.target
[Mount]
What=/dev/disk/by-label/VAR
Where=/sysroot/var
Type=auto
Options=rw
EOF
fi
3 changes: 2 additions & 1 deletion dracut/30ignition/ignition-files.service
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Requires=initrd-setup-root.service
After=initrd-setup-root.service
# Already mount the OEM partition here so that it works to write files
# without having to declare it as initrd mount in Ignition
RequiresMountsFor=/sysroot/usr/ /sysroot/oem/
RequiresMountsFor=/sysroot/usr/ /sysroot/oem/ /sysroot/var/

OnFailure=emergency.target
OnFailureJobMode=isolate
Expand All @@ -32,4 +32,5 @@ RemainAfterExit=yes
EnvironmentFile=/run/ignition.env
# Flatcar: Make sure that the OEM mount point is there even if it shortly was away
ExecStartPre=-systemctl start sysroot-oem.mount
ExecStartPre=-systemctl start sysroot-var.mount
ExecStart=/usr/bin/ignition --root=/sysroot --platform=${PLATFORM_ID} --stage=files --log-to-stdout
1 change: 1 addition & 0 deletions dracut/30ignition/ignition-mount.service
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,6 @@ RemainAfterExit=yes
EnvironmentFile=/run/ignition.env
# Flatcar: Unmount any OEM mount in case the Ignition config has one defined
ExecStartPre=/bin/bash -c 'if ! mount | grep -m 1 /sysroot/oem | grep tmpfs; then umount /sysroot/oem || true; fi'
ExecStartPre=/bin/bash -c 'if mount | grep -m 1 /sysroot/var; then umount /sysroot/var || true; fi'
ExecStart=/usr/bin/ignition --root=/sysroot --platform=${PLATFORM_ID} --stage=mount --log-to-stdout
ExecStop=/usr/bin/ignition --root=/sysroot --platform=${PLATFORM_ID} --stage=umount --log-to-stdout

0 comments on commit 8801285

Please sign in to comment.