|
|
b35c50 |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
b35c50 |
From: Jonathan Lebon <jonathan@jlebon.com>
|
|
|
b35c50 |
Date: Wed, 17 Aug 2022 10:26:03 -0400
|
|
|
b35c50 |
Subject: [PATCH] squish: BLS: only write /etc/kernel/cmdline if writable
|
|
|
b35c50 |
|
|
|
b35c50 |
On OSTree systems, `grub2-mkconfig` is run with `/etc` mounted read-only
|
|
|
b35c50 |
because as part of the promise of transactional updates, we want to make
|
|
|
b35c50 |
sure that we're not modifying the current deployment's state (`/etc` or
|
|
|
b35c50 |
`/var`).
|
|
|
b35c50 |
|
|
|
b35c50 |
This conflicts with 0837dcdf1 ("BLS: create /etc/kernel/cmdline during
|
|
|
b35c50 |
mkconfig") which wants to write to `/etc/kernel/cmdline`. I'm not
|
|
|
b35c50 |
exactly sure on the background there, but based on the comment I think
|
|
|
b35c50 |
the intent is to fulfill grubby's expectation that the file exists.
|
|
|
b35c50 |
|
|
|
b35c50 |
However, in systems like Silverblue, kernel arguments are managed by the
|
|
|
b35c50 |
rpm-ostree stack and grubby is not shipped at all.
|
|
|
b35c50 |
|
|
|
b35c50 |
Adjust the script slightly so that we only write `/etc/kernel/cmdline`
|
|
|
b35c50 |
if the parent directory is writable.
|
|
|
b35c50 |
|
|
|
b35c50 |
In the future, we're hoping to simplify things further on rpm-ostree
|
|
|
b35c50 |
systems by not running `grub2-mkconfig` at all since libostree already
|
|
|
b35c50 |
directly writes BLS entries. Doing that would also have avoided this,
|
|
|
b35c50 |
but ratcheting it into existing systems needs more careful thought.
|
|
|
b35c50 |
|
|
|
b35c50 |
Signed-off-by: Jonathan Lebon <jonathan@jlebon.com>
|
|
|
b35c50 |
|
|
|
b35c50 |
Fixes: https://github.com/fedora-silverblue/issue-tracker/issues/322
|
|
|
b35c50 |
---
|
|
|
b35c50 |
util/grub.d/10_linux.in | 13 +++++++------
|
|
|
b35c50 |
1 file changed, 7 insertions(+), 6 deletions(-)
|
|
|
b35c50 |
|
|
|
b35c50 |
diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in
|
|
|
b35c50 |
index 5d1fa072f2..4795a63b4c 100644
|
|
|
b35c50 |
--- a/util/grub.d/10_linux.in
|
|
|
b35c50 |
+++ b/util/grub.d/10_linux.in
|
|
|
b35c50 |
@@ -161,12 +161,13 @@ update_bls_cmdline()
|
|
|
b35c50 |
local cmdline="root=${LINUX_ROOT_DEVICE} ro ${GRUB_CMDLINE_LINUX} ${GRUB_CMDLINE_LINUX_DEFAULT}"
|
|
|
b35c50 |
local -a files=($(get_sorted_bls))
|
|
|
b35c50 |
|
|
|
b35c50 |
- if [[ ! -f /etc/kernel/cmdline ]] ||
|
|
|
b35c50 |
- [[ /etc/kernel/cmdline -ot /etc/default/grub ]]; then
|
|
|
b35c50 |
- # anaconda has the correct information to create this during install;
|
|
|
b35c50 |
- # afterward, grubby will take care of syncing on updates. If the user
|
|
|
b35c50 |
- # has modified /etc/default/grub, try to cope.
|
|
|
b35c50 |
- echo "$cmdline" > /etc/kernel/cmdline
|
|
|
b35c50 |
+ if [ -w /etc/kernel ] &&
|
|
|
b35c50 |
+ [[ ! -f /etc/kernel/cmdline ||
|
|
|
b35c50 |
+ /etc/kernel/cmdline -ot /etc/default/grub ]]; then
|
|
|
b35c50 |
+ # anaconda has the correct information to create this during install;
|
|
|
b35c50 |
+ # afterward, grubby will take care of syncing on updates. If the user
|
|
|
b35c50 |
+ # has modified /etc/default/grub, try to cope.
|
|
|
b35c50 |
+ echo "$cmdline" > /etc/kernel/cmdline
|
|
|
b35c50 |
fi
|
|
|
b35c50 |
|
|
|
b35c50 |
for bls in "${files[@]}"; do
|