after each sysupgrade, the boot of my x86 system with a USB keyboard and VGA display, but no serial console, hangs in grub's selection menu. Getting the system to boot requires physically pressing the Enter key on the keyboard.
Well, I feel this is a bug because it requires physical access to the machine after each sysupgrade and this can't the nominal behavior. I've got 6 other devices of several brands/models that do not expose that behavior.
And I consider the solution here a work-around because it just avoids physical access after subsequent reboots, but does not help during upgrades.
Or is there a way to disable serial in /boot/grub/grub.cfg after a sysupgrade but before reboot?
The only way I can think of right now would be to add /boot/grub/grub.cfg to the list of files to restore in /etc/sysupgrade.conf but that feels risky, isn't it?
I know I don't have a serial console, I'm just surprised it is assumed all x86-64 setups have one.
Maybe it could be checked during the sysupgrade process to adapt the grub.cfg accordingly. Hence the usefulness of a bug report. I'll open one if I do not find any existing solution my issue.
I came up with the following dirty hack in /etc/rc.local that will patch /lib/upgrade/platform.sh on the firstboot after a sysupgrade. Then the next sysupgrade will in turn patch /boot/grub/grub.cfg before rebooting:
if [ ! -f /root/firstboot ] ; then
# Patch /lib/upgrade/platform.sh
cp -a /lib/upgrade/platform.sh /lib/upgrade/platform.sh.orig
sed -i "/^\t\tmount -t ext4 -o rw,noatime \"\/dev\/\$partdev\" \/mnt/a \\\t\tsed -i 's\/^serial\/#serial\/g' \/mnt\/boot\/grub\/grub.cfg\n\t\tsed -i 's\/^terminal_input\/#terminal_input\/g' \/mnt\/boot\/grub\/grub.cfg" /lib/upgrade/platform.sh
# Mark first boot complete
The resulting patch:
diff -u /lib/upgrade/platform.sh.orig /lib/upgrade/platform.sh
--- /lib/upgrade/platform.sh.orig 2020-09-06 16:19:39.000000000 +0000
+++ /lib/upgrade/platform.sh 2020-09-27 08:45:53.299999573 +0000
@@ -39,6 +39,8 @@
if export_partdevice partdev 1; then
mount -t ext4 -o rw,noatime "/dev/$partdev" /mnt
+ sed -i 's/^serial/#serial/g' /mnt/boot/grub/grub.cfg
+ sed -i 's/^terminal_input/#terminal_input/g' /mnt/boot/grub/grub.cfg
cp -af "$UPGRADE_BACKUP" "/mnt/$BACKUP_FILE"
Also, /etc/rc.local is added to /etc/sysupgrade.conf to be restored after sysupgrades. (edit: not needed, /etc/rc.local is restored by default on sysupgrades).
Good to know, but it won't help for my use case as the scripts in /etc/uci-defaults are deleted upon success or re-executed on next boot until success. I need the script to be executed only once at each first boot after sysupgrade, but not deleted.