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.
I'm not sure why you consider this a workaround or a bug. You clearly understand why you have to disable serial on a machine without it...but yes, feel free to make a bug report. It doesn't hurt.
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?
Of course, since you don't have a serial port (you're making it seem like you don't understand that).
Ummmm...yea!
Simply make the image with the proper config for you! Then you can Sysupgrade all day remotely (which is not advised anyways, physical access is always suggested)!
Not possible...well it is an x86, so I would say...not suggested, but why not try!
It should work with the ext4 image.......oops...my apologies...you cannot sysupgrade that nope...you can't edit the files in the image.
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
touch /root/firstboot
fi
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"
umount /mnt
fi
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).
That looks cleaner and if it works in both situations, i.e. with and without a serial console, maybe that could be implemented in openwrt images for x86 platforms.
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.