diff options
author | Tomasz Maciej Nowak <tomek_n@o2.pl> | 2020-01-14 18:45:44 +0100 |
---|---|---|
committer | Petr Štetiar <ynezz@true.cz> | 2020-03-01 21:36:00 +0100 |
commit | b322243d2f768a04a04831c45dabc627a41c4570 (patch) | |
tree | 162013f56e86a8d63c1e451d59682d3ef3991970 /target/linux/x86/base-files/lib/upgrade | |
parent | 48873ace4e4bca9cb5de05b7e0a229c221bece34 (diff) | |
download | upstream-b322243d2f768a04a04831c45dabc627a41c4570.tar.gz upstream-b322243d2f768a04a04831c45dabc627a41c4570.tar.bz2 upstream-b322243d2f768a04a04831c45dabc627a41c4570.zip |
x86: add bootloader upgrade on sysupgrade
Currently bootloader always stays on the same version as when first
written to boot medium (not true if partition layout changed, which will
trigger sysupgrade process to write full disk image). That creates
inconveniences as it always stays with same features or/and bugs. Users
wishing to add support to additional modules or new version, would need
to write the whole image, potentially destroying previous system
configuration. To fix these, this commit adds additional routine to
sysupgrade which upgrades unconditionally the bootloader to the latest
state provided by OpenWrt.
Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
Diffstat (limited to 'target/linux/x86/base-files/lib/upgrade')
-rw-r--r-- | target/linux/x86/base-files/lib/upgrade/platform.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh index 3b6c25877f..8be96dfcd4 100644 --- a/target/linux/x86/base-files/lib/upgrade/platform.sh +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh @@ -1,3 +1,5 @@ +RAMFS_COPY_BIN='grub-bios-setup' + platform_check_image() { local diskdev partdev diff [ "$#" -gt 1 ] && return 1 @@ -44,6 +46,26 @@ platform_copy_config() { fi } +platform_do_bootloader_upgrade() { + local bootpart + local diskdev="$1" + + if export_partdevice bootpart 1; then + mkdir -p /tmp/boot + mount -o rw,noatime "/dev/$bootpart" /tmp/boot + echo "(hd0) /dev/$diskdev" > /tmp/device.map + + echo "Upgrading bootloader on /dev/$diskdev..." + grub-bios-setup \ + -m "/tmp/device.map" \ + -d "/tmp/boot/boot/grub" \ + -r "hd0,msdos1" \ + "/dev/$diskdev" + + umount /tmp/boot + fi +} + platform_do_upgrade() { local diskdev partdev diff @@ -92,4 +114,6 @@ platform_do_upgrade() { #copy partition uuid echo "Writing new UUID to /dev/$diskdev..." get_image "$@" | dd of="/dev/$diskdev" bs=1 skip=440 count=4 seek=440 conv=fsync + + platform_do_bootloader_upgrade "$diskdev" } |