Skip to content

Commit

Permalink
initrd-setup-root: Clean up whiteout entries for files to be recreated
Browse files Browse the repository at this point in the history
The removal of files in the overlay present in the lowerdir creates
whiteout entries that mask the lowerdir entries. For those files that
have a tmpfile rule for creation, a reboot would cause the file to be
created in the upperdir, meaning this file is not updated from the
lowerdir when it changes. In addition we have filtered out some tmpfile
rules that caused upcopies (symlinks and directories) which meant that
removing the /etc/resolv.conf symlink didn't bring it back after reboot.
To make files from the lowerdir show up if they have a tmpfile rule that
normally would recreate them we keep a list of whiteout entries that we
clean up on boot. This also prevents freezing files because
systemd-tmpfiles does not need to recreate them in the upperdir.
  • Loading branch information
pothos committed Nov 29, 2023
1 parent 10cea16 commit 201d973
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions dracut/99setup-root/initrd-setup-root
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,14 @@ mkdir -p /sysroot/etc
if [ ! -e "/sysroot/etc/.no-dup-update" ]; then
walksysroot /etc overlaycleanup
fi
# Also, remove any user-created whiteouts for files that have a tmpfiles
# rule that normally would recreate them (we use the lowerdir for that).
while IFS="" read -r entry ; do
entry="/sysroot${entry}"
if [ -c "${entry}" ] && [ "$(stat --printf='%Hr %Lr\n' "${entry}")" = "0 0" ]; then
rm "${entry}" || true
fi
done < /sysroot/usr/share/flatcar/etc-no-whiteouts

# Set up overlay mount for /etc (as long as we can't use syscfg for that)
mkdir -p /sysroot/.etc-work
Expand Down

0 comments on commit 201d973

Please sign in to comment.