Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip: separate /var #75

Draft
wants to merge 1 commit into
base: flatcar-master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should that be

Suggested change
add_wants sysroot-oem.mount
add_wants sysroot-var.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