fix(scripts): report the grub.cfg default entry, and stop claiming what was checked
The pending-entry grep anchored on "menuentry 'Ubuntu'" with -A4 and matched no linux line, so the script printed nothing where it should have shown the next boot's command line; the PENDING line then said "is in grub.cfg" when the loop only ever compared the tracked file against /proc/cmdline. Now the default entry's linux line is parsed with awk (first linux line of the first Ubuntu menuentry, which is what GRUB_DEFAULT=0 selects), its iommu token is printed, and a mismatch against the tracked file warns by name.
This commit is contained in:
@@ -46,8 +46,14 @@ else
|
||||
sudo update-grub
|
||||
fi
|
||||
|
||||
echo "== pending entry"
|
||||
sudo grep -m1 "menuentry 'Ubuntu'" -A4 /boot/grub/grub.cfg | grep -m1 linux | tr ' ' '\n' | grep -E '^(iommu|amd_iommu)' || true
|
||||
# The DEFAULT entry is the first 'Ubuntu' menuentry's linux line: that is the
|
||||
# command line the next boot actually gets. (GRUB_DEFAULT=0 here, so first it is.)
|
||||
echo "== grub.cfg default entry"
|
||||
CFG="$(sudo awk '/menuentry .Ubuntu/ && !seen {seen=1}
|
||||
seen && /^[[:space:]]*linux/ {print; exit}' /boot/grub/grub.cfg)"
|
||||
[ -n "$CFG" ] || { echo "could not read the default linux line from grub.cfg" >&2; exit 1; }
|
||||
printf '%s\n' "$CFG" | tr ' \t' '\n' | grep -E '^(iommu|amd_iommu)=' || echo "(no iommu token in the default entry)"
|
||||
|
||||
echo "== running kernel"
|
||||
tr '\0' ' ' < /proc/cmdline; echo
|
||||
|
||||
@@ -56,9 +62,14 @@ NOW="$(cat /proc/cmdline)"
|
||||
for tok in $WANT; do
|
||||
case " $NOW " in
|
||||
*" $tok "*) ;;
|
||||
*) echo "PENDING: '$tok' is in grub.cfg but not in the running kernel — needs a reboot" ;;
|
||||
*) echo "PENDING: '$tok' is not in the running kernel" ;;
|
||||
esac
|
||||
done
|
||||
WANT_IOMMU="$(printf '%s\n' $WANT | grep -E '^(iommu|amd_iommu)=' | head -1)"
|
||||
CFG_IOMMU="$(printf '%s\n' "$CFG" | tr ' \t' '\n' | grep -E '^(iommu|amd_iommu)=' | head -1)"
|
||||
if [ "$WANT_IOMMU" != "$CFG_IOMMU" ]; then
|
||||
echo "WARN: grub.cfg default entry says '${CFG_IOMMU:-none}', tracked file says '${WANT_IOMMU:-none}'" >&2
|
||||
fi
|
||||
|
||||
if [ "$REBOOT" = 1 ]; then
|
||||
echo "== rebooting now"
|
||||
|
||||
Reference in New Issue
Block a user