Bug 246494 - [PATCH] misc: add the boot flag to the i386 memstick.img release (MBR)
Summary: [PATCH] misc: add the boot flag to the i386 memstick.img release (MBR)
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: i386 Any
: --- Affects Only Me
Assignee: Ed Maste
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2020-05-16 05:56 UTC by Jorge Maidana
Modified: 2020-05-24 18:28 UTC (History)
1 user (show)

See Also:


Attachments
release/i386/make-memstick.sh patch (414 bytes, patch)
2020-05-16 05:56 UTC, Jorge Maidana
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jorge Maidana 2020-05-16 05:56:58 UTC
Created attachment 214543 [details]
release/i386/make-memstick.sh patch

The UFS partition of the i386 memstick.img is missing the boot flag.
Comment 1 Ed Maste freebsd_committer 2020-05-21 21:37:24 UTC
I observed a failure on a Lenovo X220 while attempting to use FreeBSD-13.0-CURRENT-i386-20200521-r361307-mini-memstick.img.xz due to this issue; the system reported

Non-system disk
Press any key to reboot

Fixed by running from another machine:
# gpart set -a active -i 2 da0

This patch looks correct and I'll take care of it; we'll also need to figure out how far back this broke.
Comment 2 Ed Maste freebsd_committer 2020-05-21 21:53:12 UTC
It looks like this was probably introduced by r342283 which added a 2nd partition to the i386 memstick. That change was actually a mistake for i386 though, as we do not have any EFI boot support for i386, so we should revert the i386 part of r342283.
Comment 3 Ed Maste freebsd_committer 2020-05-24 18:12:34 UTC
By default mkimg makes the first partition active, if no -a flag:

# gpart show md0
=>     1  712744  md0  MBR  (348M)
       1   66584    1  efi  [active]  (33M)
   66585  646160    2  freebsd  (316M)

We need to at least revert the i386 part of r342283, which will restore the active flag on the bootcode-containing UFS partition. We may want to also explicitly specify `-a 1` in the hope that someone making a change similar to r342283 in the future will realize the need to update it, but it's not strictly necessary.
Comment 4 commit-hook freebsd_committer 2020-05-24 18:26:34 UTC
A commit references this bug:

Author: emaste
Date: Sun May 24 18:25:50 UTC 2020
New revision: 361437
URL: https://svnweb.freebsd.org/changeset/base/361437

Log:
  Make i386 memstick images bootable.

  This reverts the i386 part of r342283, "Rework UEFI ESP generation", and
  the followup commit in r342690.

  r342283 added an ESP to the i386 memstick image, and as a side effect
  made the ESP the active partition, not the bootcode-containing UFS
  partition.  As a result the i386 memstick images would not boot in
  either UEFI or legacy mode - UEFI failed because we do not support i386
  UEFI booting, and legacy mode failed because the partition with legacy
  bootcode was not active.

  The bootcode-containing UFS partition is again the only, and active,
  partition.

  PR:		246494
  Reported by:	Jorge Maidana
  Differential Revision:	The FreeBSD Foundation

Changes:
  head/release/i386/make-memstick.sh