Skip to content

Commit

Permalink
Prevent the OEM mount point from showing up before Ignition mounts
Browse files Browse the repository at this point in the history
Ignition may run a manual mount command for the OEM partition if the
user specifies it. This fails if the OEM mount unit is triggered early,
because it can't be mounted twice, thus we need to prevent that from
happening by unmounting the OEM partition (but not the tmpfs OEM mount
for PXE-provided OEM contents). To spare users from even dealing with
the OEM partition specification in Ignition we can ensure it is mounted
before Ignition writes files.
  • Loading branch information
pothos committed Mar 18, 2023
1 parent 8454832 commit 2fb5a75
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions dracut/10diskless-generator/diskless-generator
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ if [[ "${copy_oem}" -eq 1 ]]; then
# Automatically generated by diskless-generator
[Unit]
# This runs early for initrd-setup-root to populate it.
# Ignition can mount something else on /usr/share/oem still
# if the user wants so.
Before=initrd-root-fs.target
[Mount]
Expand Down
3 changes: 3 additions & 0 deletions dracut/30ignition/ignition-files.service
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ After=ignition-setup.service ignition-disks.service
# setup the root filesystem before we try do things like create users on it.
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/usr/share/oem/

OnFailure=emergency.target
OnFailureJobMode=isolate
Expand Down
2 changes: 2 additions & 0 deletions dracut/30ignition/ignition-mount.service
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ After=ignition-setup.service
Type=oneshot
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/usr/share/oem | grep tmpfs; then umount /sysroot/usr/share/oem || 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 2fb5a75

Please sign in to comment.