diff mbox series

x86: check for gpt header in platform_check_image

Message ID qberbmd4uximjlzqqi4gd7soejfmlnkrxwmwlzxczhen4mnao3@227vby5zhsnc
State New
Headers show
Series x86: check for gpt header in platform_check_image | expand

Commit Message

Jonas Lochmann Jan. 3, 2026, 4:30 p.m. UTC
The previous check only looked for specific boot code in the MBR.
The previous check is still kept as a fallback path.

Signed-off-by: Jonas Lochmann <openwrt@jonaslochmann.de>
---
 .../linux/x86/base-files/lib/upgrade/platform.sh | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Philip Prindeville Jan. 12, 2026, 11:36 p.m. UTC | #1
The sender domain has a DMARC Reject/Quarantine policy which disallows
sending mailing list messages using the original "From" header.

To mitigate this problem, the original message has been wrapped
automatically by the mailing list software.
While you're in there, can you fix the partition table stuff so that /var can be made persistent?  Possibly adding a package that converts a system that didn't have a persistent /var to one that creates a partition out of the remaining free space, formats it, creates the appropriate subdirectories, and writes out an /etc/fstab entry...



> On Jan 3, 2026, at 9:30 AM, Jonas Lochmann <openwrt@jonaslochmann.de> wrote:
> 
> The previous check only looked for specific boot code in the MBR.
> The previous check is still kept as a fallback path.
> 
> Signed-off-by: Jonas Lochmann <openwrt@jonaslochmann.de>
> ---
> .../linux/x86/base-files/lib/upgrade/platform.sh | 16 +++++++++-------
> 1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
> index 5dad7a538a..719ab49963 100644
> --- a/target/linux/x86/base-files/lib/upgrade/platform.sh
> +++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
> @@ -4,13 +4,15 @@ platform_check_image() {
> local diskdev partdev diff
> [ "$#" -gt 1 ] && return 1
> 
> - case "$(get_magic_word "$1")" in
> - eb48|eb63) ;;
> - *)
> - v "Invalid image type"
> - return 1
> - ;;
> - esac
> + part_magic_efi "$1" || {
> + case "$(get_magic_word "$1")" in
> + eb48|eb63) ;;
> + *)
> + v "Invalid image type"
> + return 1
> + ;;
> + esac
> + }
> 
> export_bootdevice && export_partdevice diskdev 0 || {
> v "Unable to determine upgrade device"
> -- 
> 2.47.3
> 
> 
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Jonas Lochmann Jan. 14, 2026, 7:40 p.m. UTC | #2
Am Mon, Jan 12, 2026 at 04:36:11PM -0700, schrieb Philip Prindeville:
> While you're in there, can you fix the partition table stuff so that /var can be made persistent?

That's completly unrelated to this topic.

> Possibly adding a package that converts a system that didn't have a
> persistent /var to one that creates a partition out of the remaining
> free space, formats it, creates the appropriate subdirectories, and
> writes out an /etc/fstab entry...

That's a very bad design idea. This is a very bad fit for an extra
package and adjusting the partition layout by installing a package
is a bad idea like programatically updating the fstab file. We
don't have systemd and its mount units here, but there are other
methods to mount something.

The traditional GPT is too unflexible for that - the OpenWrt image
size could change. Or you have your custom partition first and OpenWrt
in the end so that shrinking the extra partition later is possible.

So to make the extra partition possible, the sysupgrade process
would need to extract the new efi and system partition to replace
this partitions only. Then you can do what you want with the
remaining disk - as long as no one increases the partition sizes
because updates would fail then.
Philip Prindeville Jan. 20, 2026, 8:40 p.m. UTC | #3
The sender domain has a DMARC Reject/Quarantine policy which disallows
sending mailing list messages using the original "From" header.

To mitigate this problem, the original message has been wrapped
automatically by the mailing list software.
> On Jan 14, 2026, at 12:40 PM, Jonas Lochmann <openwrt@jonaslochmann.de> wrote:
> 
> Am Mon, Jan 12, 2026 at 04:36:11PM -0700, schrieb Philip Prindeville:
>> While you're in there, can you fix the partition table stuff so that /var can be made persistent?
> 
> That's completly unrelated to this topic.
> 
>> Possibly adding a package that converts a system that didn't have a
>> persistent /var to one that creates a partition out of the remaining
>> free space, formats it, creates the appropriate subdirectories, and
>> writes out an /etc/fstab entry...
> 
> That's a very bad design idea. This is a very bad fit for an extra
> package and adjusting the partition layout by installing a package
> is a bad idea like programatically updating the fstab file. We
> don't have systemd and its mount units here, but there are other
> methods to mount something.


What's worse design is having different behavior on different platforms.

As @dangowrt pointed out, setting up an x86 box to use an SSD or NVMe to have persistent /var is hard to do because of the way it operates differently from every other platform.

-Philip



> 
> The traditional GPT is too unflexible for that - the OpenWrt image
> size could change. Or you have your custom partition first and OpenWrt
> in the end so that shrinking the extra partition later is possible.
> 
> So to make the extra partition possible, the sysupgrade process
> would need to extract the new efi and system partition to replace
> this partitions only. Then you can do what you want with the
> remaining disk - as long as no one increases the partition sizes
> because updates would fail then.
diff mbox series

Patch

diff --git a/target/linux/x86/base-files/lib/upgrade/platform.sh b/target/linux/x86/base-files/lib/upgrade/platform.sh
index 5dad7a538a..719ab49963 100644
--- a/target/linux/x86/base-files/lib/upgrade/platform.sh
+++ b/target/linux/x86/base-files/lib/upgrade/platform.sh
@@ -4,13 +4,15 @@  platform_check_image() {
 	local diskdev partdev diff
 	[ "$#" -gt 1 ] && return 1
 
-	case "$(get_magic_word "$1")" in
-		eb48|eb63) ;;
-		*)
-			v "Invalid image type"
-			return 1
-		;;
-	esac
+	part_magic_efi "$1" || {
+		case "$(get_magic_word "$1")" in
+			eb48|eb63) ;;
+			*)
+				v "Invalid image type"
+				return 1
+			;;
+		esac
+	}
 
 	export_bootdevice && export_partdevice diskdev 0 || {
 		v "Unable to determine upgrade device"