Bug 227954 - FreeBSD memstick doesn't boot off of non-efi systems
Summary: FreeBSD memstick doesn't boot off of non-efi systems
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Some People
Assignee: Ed Maste
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-05-03 16:43 UTC by takedown.man
Modified: 2022-10-05 04:36 UTC (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description takedown.man 2018-05-03 16:43:56 UTC
While writing an mini-memstick image of the FreeBSD operating system onto a USB, the said USB doesn't boot off of an non-EFI system
Comment 1 Ed Maste freebsd_committer freebsd_triage 2018-05-05 01:00:43 UTC
I have booted FreeBSD memstick images in both UEFI and CSM (legacy BIOS) modes.

Please report back with the specific memstick image and hardware that you tested.
Comment 2 takedown.man 2018-05-05 08:24:00 UTC
(In reply to Ed Maste from comment #1)
I used the "FreeBSD-11.1-RELEASE-amd64-memstick.img"
And my hardware is as follows

CPU
	Intel Pentium 4 630
	Prescott 90nm Technology
RAM
	2.00GB Dual-Channel DDR2 @ 332MHz (5-5-5-15)
Motherboard
	Hewlett-Packard 09F0h (XU1 PROCESSOR)	58 °C
Graphics
	W1946 (1360x768@60Hz)
	1024MB NVIDIA GeForce 210 (ZOTAC International)	43 °C
Storage
	74GB Western Digital WDC WD800JD-60LSA5 ATA Device (SATA)	33 °C
Optical Drives
	LITE-ON DVD SOHD-16P9S ATA Device
Audio
	Realtek High Definition Audio
Comment 3 Glen Barber freebsd_committer freebsd_triage 2018-05-07 15:25:04 UTC
Can you try with the most recent 11.2-PRERELEASE image?  There have been a few changes to how the images are created, which I believe may resolve this.

https://download.freebsd.org/ftp/snapshots/ISO-IMAGES/11.2/FreeBSD-11.2-PRERELEASE-amd64-20180504-r333226-memstick.img
Comment 4 Ed Maste freebsd_committer freebsd_triage 2018-05-28 17:21:45 UTC
There are two changes in review for this issue:

* https://reviews.freebsd.org/D15598 (by imp@)
* https://reviews.freebsd.org/D15599

I have a test image built with D15598 and the equivalent of D15599 at https://people.freebsd.org/~emaste/mini-image-2018-05-28-amd64.xz  Can you uncompress and write it to a memstick and see if it boots on your hardware?
Comment 5 commit-hook freebsd_committer freebsd_triage 2018-05-29 15:07:07 UTC
A commit references this bug:

Author: emaste
Date: Tue May 29 15:06:13 UTC 2018
New revision: 334337
URL: https://svnweb.freebsd.org/changeset/base/334337

Log:
  switch amd64 memstick installer images to MBR

  A good number of BIOSes have trouble booting from GPT in non-UEFI mode.
  This is commonly reported with Lenovo desktops and laptops (including
  X220, X230, T430, and E31) and Dell systems.  Although UEFI is the
  preferred amd64 boot method on recent hardware, older hardware does not
  support UEFI, a user may wish to boot via BIOS/CSM, and some systems
  that support UEFI fail to boot FreeBSD via UEFI (such as an old
  AMD FX-6100 that I have).

  With this change amd64 memsticks remain dual-mode (booting from either
  UEFI or CSM); the partitioning type is just switched from GPT to MBR.

  The "vestigial swap partition" in the GPT scheme was added in r265017 to
  work around some issue with loader's GPT support, so we should not need
  it when using MBR.

  There is some concern that future UEFI systems may not boot from MBR,
  but I am not aware of any today.  In any case the likely path forward
  for our installers is to migrate to CD/USB combo images, and if it
  becomes necessary introduce a separate memstick specifically for the
  MBR BIOS/CSM case.

  PR:		227954
  Reviewed by:	gjb, imp, tsoome
  MFC after:	3 days
  Relnotes:	Yes
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D15599

Changes:
  head/release/amd64/make-memstick.sh
Comment 6 Ed Maste freebsd_committer freebsd_triage 2018-05-29 15:25:30 UTC
The next -current snapshot builds will include the switch to MBR partitioning. I hope to receive a number of test reports on those (or the test image I built) before MFCing the change to 11 for RC2.
Comment 7 commit-hook freebsd_committer freebsd_triage 2018-05-31 20:02:24 UTC
A commit references this bug:

Author: gjb
Date: Thu May 31 20:01:59 UTC 2018
New revision: 334444
URL: https://svnweb.freebsd.org/changeset/base/334444

Log:
  MFC r334310, r334337:

   r334310 (imp):
    Teach ufs_module.c about bsd labels and probe 'a' partition.

    If the check for a UFS partition at offset 0 on the disk fails, check
    to see if there's a BSD disklabel at block 1 (standard) or at offset
    512 (install images assume 512 sector size). If found, probe for UFS
    on the 'a' partition.

    This fixes UEFI booting images from a BSD labeled MBR slice when the
    'a' partiton isn't at offset 0. This is a stop-gap fix since we plan
    on removing boot1.efi in FreeBSD 12. We can't easily do that for 11.2,
    however, hence the short MFC window.

   r334337 (emaste):
    switch amd64 memstick installer images to MBR

    A good number of BIOSes have trouble booting from GPT in non-UEFI
    mode.

    With this change amd64 memsticks remain dual-mode (booting from either
    UEFI or CSM); the partitioning type is just switched from GPT to MBR.

  PR:		227954

  Note, there are two changes specific to stable/11 where there is code
  that had diverged from head and never merged back.  The two changes are
  an include in stand/efi/boot1/ufs_module.c, replacing sys/disk/bsd.h
  with sys/disklabel.h and replacing BSD_MAGIC with DISKMAGIC in the
  same file.  The latter two are direct commits to stable/11 in order to
  avoid unexpected regressions at this point of the 11.2 cycle.  Thank
  you to imp@ for pointing out what changes needed to be made.

  Approved by:	re (marius)

  Sponsored by:	The FreeBSD Foundation

Changes:
_U  stable/11/
  stable/11/release/amd64/make-memstick.sh
  stable/11/stand/efi/boot1/boot_module.h
  stable/11/stand/efi/boot1/ufs_module.c
Comment 8 Ed Maste freebsd_committer freebsd_triage 2018-10-04 01:24:33 UTC
jollyjester, can you please try one of the recent snapshot images on your machine and check that this is fixed?
Comment 9 Petr Ketner 2018-11-16 12:08:13 UTC
(In reply to commit-hook from comment #5)

This commit breaks UEFI specification and the memstick will/does not boot on most if not all UEFI-only machines (Tested on Asus E203NA).

https://superuser.com/questions/563074/do-hard-drives-need-a-guid-partition-table-gpt-to-boot-in-uefi-mode

The hybrid ISO image dd'd to USB flash works fine. Handbook should probably mention that the ISO can be used with USB flash.
Comment 10 Jerry Jacobs 2022-10-04 17:32:56 UTC
I get the same "Missing operating system" for an old (probably) non-EFI system with "FreeBSD-13.1-RELEASE-amd64-memstick.img". I dd'ed the img with macOS onto the USB stick and tried to boot from it.

System is:
  MSI Wind Box DE200 nettop custom form-factor (MS-7467).
  hw.model: Intel(R) Atom(TM) CPU  330   @ 1.60GHz

pciconf -lv
```
hostb0@pci0:0:0:0:	class=0x060000 rev=0x02 hdr=0x00 vendor=0x8086 device=0x2770 subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = '82945G/GZ/P/PL Memory Controller Hub'
    class      = bridge
    subclass   = HOST-PCI
hdac0@pci0:0:27:0:	class=0x040300 rev=0x01 hdr=0x00 vendor=0x8086 device=0x27d8 subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = 'NM10/ICH7 Family High Definition Audio Controller'
    class      = multimedia
    subclass   = HDA
pcib1@pci0:0:28:0:	class=0x060400 rev=0x01 hdr=0x01 vendor=0x8086 device=0x27d0 subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = 'NM10/ICH7 Family PCI Express Port 1'
    class      = bridge
    subclass   = PCI-PCI
pcib2@pci0:0:28:1:	class=0x060400 rev=0x01 hdr=0x01 vendor=0x8086 device=0x27d2 subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = 'NM10/ICH7 Family PCI Express Port 2'
    class      = bridge
    subclass   = PCI-PCI
pcib3@pci0:0:28:2:	class=0x060400 rev=0x01 hdr=0x01 vendor=0x8086 device=0x27d4 subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = 'NM10/ICH7 Family PCI Express Port 3'
    class      = bridge
    subclass   = PCI-PCI
uhci0@pci0:0:29:0:	class=0x0c0300 rev=0x01 hdr=0x00 vendor=0x8086 device=0x27c8 subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = 'NM10/ICH7 Family USB UHCI Controller'
    class      = serial bus
    subclass   = USB
uhci1@pci0:0:29:1:	class=0x0c0300 rev=0x01 hdr=0x00 vendor=0x8086 device=0x27c9 subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = 'NM10/ICH7 Family USB UHCI Controller'
    class      = serial bus
    subclass   = USB
uhci2@pci0:0:29:2:	class=0x0c0300 rev=0x01 hdr=0x00 vendor=0x8086 device=0x27ca subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = 'NM10/ICH7 Family USB UHCI Controller'
    class      = serial bus
    subclass   = USB
uhci3@pci0:0:29:3:	class=0x0c0300 rev=0x01 hdr=0x00 vendor=0x8086 device=0x27cb subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = 'NM10/ICH7 Family USB UHCI Controller'
    class      = serial bus
    subclass   = USB
ehci0@pci0:0:29:7:	class=0x0c0320 rev=0x01 hdr=0x00 vendor=0x8086 device=0x27cc subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = 'NM10/ICH7 Family USB2 EHCI Controller'
    class      = serial bus
    subclass   = USB
pcib4@pci0:0:30:0:	class=0x060401 rev=0xe1 hdr=0x01 vendor=0x8086 device=0x244e subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = '82801 PCI Bridge'
    class      = bridge
    subclass   = PCI-PCI
isab0@pci0:0:31:0:	class=0x060100 rev=0x01 hdr=0x00 vendor=0x8086 device=0x27b8 subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = '82801GB/GR (ICH7 Family) LPC Interface Bridge'
    class      = bridge
    subclass   = PCI-ISA
atapci0@pci0:0:31:1:	class=0x01018a rev=0x01 hdr=0x00 vendor=0x8086 device=0x27df subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = '82801G (ICH7 Family) IDE Controller'
    class      = mass storage
    subclass   = ATA
atapci1@pci0:0:31:2:	class=0x01018f rev=0x01 hdr=0x00 vendor=0x8086 device=0x27c0 subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = 'NM10/ICH7 Family SATA Controller [IDE mode]'
    class      = mass storage
    subclass   = ATA
ichsmb0@pci0:0:31:3:	class=0x0c0500 rev=0x01 hdr=0x00 vendor=0x8086 device=0x27da subvendor=0x1462 subdevice=0x7467
    vendor     = 'Intel Corporation'
    device     = 'NM10/ICH7 Family SMBus Controller'
    class      = serial bus
    subclass   = SMBus
re0@pci0:1:0:0:	class=0x020000 rev=0x03 hdr=0x00 vendor=0x10ec device=0x8168 subvendor=0x1462 subdevice=0x7467
    vendor     = 'Realtek Semiconductor Co., Ltd.'
    device     = 'RTL8111/8168/8411 PCI Express Gigabit Ethernet Controller'
    class      = network
    subclass   = ethernet
none0@pci0:2:0:0:	class=0x028000 rev=0x10 hdr=0x00 vendor=0x10ec device=0x8172 subvendor=0x1462 subdevice=0x6897
    vendor     = 'Realtek Semiconductor Co., Ltd.'
    device     = 'RTL8191SEvB Wireless LAN Controller'
    class      = network
vgapci0@pci0:3:0:0:	class=0x030000 rev=0x00 hdr=0x00 vendor=0x1002 device=0x9552 subvendor=0x1002 subdevice=0x9552
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'RV710/M92 [Mobility Radeon HD 4330/4350/4550]'
    class      = display
    subclass   = VGA
hdac1@pci0:3:0:1:	class=0x040300 rev=0x00 hdr=0x00 vendor=0x1002 device=0xaa38 subvendor=0x1002 subdevice=0xaa38
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'RV710/730 HDMI Audio [Radeon HD 4000 series]'
    class      = multimedia
    subclass   = HDA
```
Comment 11 Jerry Jacobs 2022-10-04 17:37:37 UTC
I forgot to mention the MS-7467 system uses an American Megatrend Inc. BIOS from 2009. I tried to look into the firmware but no mention of EFI CSM mode present.
Comment 12 Jerry Jacobs 2022-10-05 04:36:36 UTC
Sorry for the noise, but I tried to also flash an ISO to the USB stick but that also failed. I must mention the usage of the pv command: "dd if=memstick.img | pv | dd of=/dev/disk3". It seemed not to write all bytes so I write with dd only and it worked perfectly with the memstick image on EFI and non-EFI systems. 

The pv (pipe viewer) command should not be used as it can be bugged by not writing all bytes. http://www.ivarch.com/programs/pv.shtml