Re: How to BIOS-boot from NVMe device?

2022-09-09 Thread Robert Elz
Date:Fri, 9 Sep 2022 11:10:36 +0200
From:Rhialto 
Message-ID:  

  | How does the UEFI system decide what to boot?

There are a whole set of variables in UEFI internal storage
One group of those are named BOOT where the  is a 4
digit hex value.  Its value is irrelevant, just serves to make
unique names.  Another variable has as its value a list of those
variables (really just a list of the (binary) 16 bit values that
make the trailing 4 hex digits).  That defines which of the
BOOT variables should be attempted, and in which order.
First to succeed wins.

The BIOS boot menu will allow you to temporarily alter the order
and its Boot config page to make more permanent alterations.
Its abilities tend to be quite limited though.

  | It obviously requires a special partition on a disk.

I don't think that is actually true.  The ESP serves two roles.
First it is a filesystem of a type the firmware is guaranteed to
be able to read.  That allows files to be placed there - but
firmware can also be taught to read other filesystems if anyone
wants to do the work.

And second, since the firmware typically provides no way to manipulate
the BOOT variables, other than adding them to, or removing them
from, and reordering the boot order variable, which is useless for
getting started from nothing, it will also look in any new ESP it
encounters for one particular file with a magic name, and create
a BOOT variable to refer to that specific file (It does similar
things for optical media, though no ESP exists there, and for
network interfaces for PXE booting).

  | But what if there are multiple files in
  | there which are potentially bootable?

Each will have a different name, a separate BOOT can be made for
each, after which each can be selected from the boot menu.
But only one can have the magic name, so only one will be created
by the firmware.

  | I was expecting some built-in UEFI
  | shell in my newest computer, so that I can handle such cases myself, or
  | something like that. However, I found no signs of such a shell (and when
  | I read about it, it generally seems to be assumed that it is indeed
  | built-in).  Also, even if I would find one as a file (I didn't find ut
  | yet) and put it in my EFI partition, I'm not sure how to start it, since
  | the system as shown no signs that it offers boot opptions more detailed
  | than "boot from a disk".

Yes the mythical UEFI shell.  All your expectations could be met, but
are unlikely to be, as building such a shell into the firmware would
more or less preclude future development.

As an external program it would be booted just like an OS, but would
never actually take over, just operate using firmware primitives.
Such a thing could be created, probably should be, but I could not
find one either.

In general the expectation seems to be that all of this is managed
from within your OS.   Unfortunately in NetBSD we are only just
beginning to im0lement the primitives necessary.  FreeBSD are a bit
more advanced.  Linux even more, though their tool is still extremely
crude.  I assume wintrash has something better, but I have no idea,
that is not my playing field.

If all you need is NetBSD just allow it to put the magic file in
the ESP, the firmware will find it, and add it to the boot menu.
You can then use that to boot NetBSD from any GPT partition.
For other OSs just let the make their own ESP, or use any existing
one, to add their boot file and create the mag8c variable.

Eventually we will do better.

kre


Re: How to BIOS-boot from NVMe device?

2022-09-09 Thread Rhialto
On Thu 08 Sep 2022 at 12:36:46 -0400, Brad Spencer wrote:
> This is a clear indication of a UEFI boot.  There is confusion in the
> docs about where the boot.cfg file should be located.  I have also found
> that the desired behavior works if it is in the root of the EFI
> filesystem.

How does the UEFI system decide what to boot? It obviously requires a
special partition on a disk. But what if there are multiple files in
there which are potentially bootable? I was expecting some built-in UEFI
shell in my newest computer, so that I can handle such cases myself, or
something like that. However, I found no signs of such a shell (and when
I read about it, it generally seems to be assumed that it is indeed
built-in).  Also, even if I would find one as a file (I didn't find ut
yet) and put it in my EFI partition, I'm not sure how to start it, since
the system as shown no signs that it offers boot opptions more detailed
than "boot from a disk".

-Olaf.
-- 
___ "Buying carbon credits is a bit like a serial killer paying someone else to
\X/  have kids to make his activity cost neutral." -The BOFHfalu.nl@rhialto


signature.asc
Description: PGP signature


re: How to BIOS-boot from NVMe device?

2022-09-08 Thread matthew green
> >  > If anyone wants to play with UEFI booting and has access to a recent Xen
> >  > DOM0 system you can install the pkgsrc/sysutils/ovmf package and point a
> > pkgsrc/sysutils/ovmf does not build on -current at least - and hasn't been 
> > building for a long while. 
>
> Hmm... unfortunate...  it does build just fine on 9.2ish from 2022Q2
> pkgsrc.

this just built for me on a ~3-day old -current src & pkgsrc
system.  Chavdar, hoe does it fail for you?


Re: How to BIOS-boot from NVMe device?

2022-09-08 Thread Brad Spencer
Chavdar Ivanov  writes:

[snip]

>  > If anyone wants to play with UEFI booting and has access to a recent Xen
>  > DOM0 system you can install the pkgsrc/sysutils/ovmf package and point a
> pkgsrc/sysutils/ovmf does not build on -current at least - and hasn't been 
> building for a long while. 

Hmm... unfortunate...  it does build just fine on 9.2ish from 2022Q2
pkgsrc.

> I checkout the source and build it manually under Debian; obviously the 
> resulting firmware files are the same. 

I didn't try doing that, but I did find that the version from Archlinux
from their package manager won't work on a -current NetBSD kernel, which
panics somehere in the ACPI code.  -current, after removing PVH and
PVHVM, worked fine on the version I built on 9.x.





-- 
Brad Spencer - b...@anduin.eldar.org - KC8VKS - http://anduin.eldar.org


Re: How to BIOS-boot from NVMe device?

2022-09-08 Thread Chavdar Ivanov




On 08 September 2022 17:36:46 (+01:00), Brad Spencer wrote:

> Paul Goyette  writes:
>
> > On Thu, 8 Sep 2022, Paul Goyette wrote:
> >
> >> Would be nice to get my menu back and have it default to the NetBSD
> >> system partition, but at least it boots!
> >
> > I got my menu back. Just had to put it at /efi/boot.cfg (ie, at the
> > root of the EFI partition).
> >
> >
> > 
++--+--+

> > | Paul Goyette | PGP Key fingerprint: | E-mail addresses: |
> > | (Retired) | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com |
> > | Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org 
|

> > | & Network Engineer | | pgoyett...@gmail.com |
> > 
++--+--+

>
>
> This is a clear indication of a UEFI boot. There is confusion in the
> docs about where the boot.cfg file should be located. I have also found
> that the desired behavior works if it is in the root of the EFI
> filesystem.
>
> If anyone wants to play with UEFI booting and has access to a recent Xen
> DOM0 system you can install the pkgsrc/sysutils/ovmf package and point a
pkgsrc/sysutils/ovmf does not build on -current at least - and hasn't been 
building for a long while. 

I checkout the source and build it manually under Debian; obviously the 
resulting firmware files are the same. 


> Xen HVM guest at that for its bios and get a more or less working UEFI
> setup without physical hardware (you will have to compile a custom
> kernel without PVM or PVHVM support). I posted a note on port-xen a bit
> ago about what works and what had trouble. You can probably do the same
> thing with qemu and/or nvmm but I have not messed with those.
>
>
>

--
Sent with Vivaldi Mail. Download Vivaldi for free at vivaldi.com


Re: How to BIOS-boot from NVMe device?

2022-09-08 Thread Brad Spencer
Paul Goyette  writes:

> On Thu, 8 Sep 2022, Paul Goyette wrote:
>
>> Would be nice to get my menu back and have it default to the NetBSD
>> system partition, but at least it boots!
>
> I got my menu back.  Just had to put it at /efi/boot.cfg (ie, at the
> root of the EFI partition).
>
>
> ++--+--+
> | Paul Goyette   | PGP Key fingerprint: | E-mail addresses:|
> | (Retired)  | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com|
> | Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org  |
> | & Network Engineer |  | pgoyett...@gmail.com |
> ++--+--+


This is a clear indication of a UEFI boot.  There is confusion in the
docs about where the boot.cfg file should be located.  I have also found
that the desired behavior works if it is in the root of the EFI
filesystem.

If anyone wants to play with UEFI booting and has access to a recent Xen
DOM0 system you can install the pkgsrc/sysutils/ovmf package and point a
Xen HVM guest at that for its bios and get a more or less working UEFI
setup without physical hardware (you will have to compile a custom
kernel without PVM or PVHVM support).  I posted a note on port-xen a bit
ago about what works and what had trouble.  You can probably do the same
thing with qemu and/or nvmm but I have not messed with those.



-- 
Brad Spencer - b...@anduin.eldar.org - KC8VKS - http://anduin.eldar.org




Re: How to BIOS-boot from NVMe device?

2022-09-08 Thread Robert Elz
Date:Thu, 8 Sep 2022 08:07:44 -0700 (PDT)
From:Paul Goyette 
Message-ID:  

  | I got my menu back.  Just had to put it at /efi/boot.cfg (ie, at the
  | root of the EFI partition).

That's interesting, not where it is supposed to be placed - I hadn't
tried putting one there (and should have).   Debugging what was going
on with efiboot and its cfg file was on my list of things to hope that
someone else fixed before I couldn't tolerate it any more...

The updated biosboot you did is probably irrelevant - I am guessing is
that somehow secureboot is no longer being attempted, you're obviously
getting a nice UEFI boot, and as long as that works, stick with it.
Eventually that boot mechanism is almost certain to allow many improvements.

Since UEFI booting is clearly enabled (which it is possible, though it would
be unusual, that your BIOS simply turns on when it finds a properly set up ESP
and has no other option) there would not be an option in the BIOS to enable it.
There should (but might not be) one to disable it though, perhaps called
something about "Legacy Boot" (or something similar), and possibly way down
the bottom (not initially visible on screen) of the BIOS (must stop calling
it that, that's the name for the ancient thing, now we have UEFI firmware)
boot page.

kre



Re: How to BIOS-boot from NVMe device?

2022-09-08 Thread Robert Elz
Date:Thu, 8 Sep 2022 07:46:14 -0700 (PDT)
From:Paul Goyette 
Message-ID:  

  | (The EFI partition is still marked ``bootme''.)

That one you should probably turn off - bootme (the UEFI "where to boot"
flag) should be on the NetBSD root partition.

Or not there at all, and the boot code will boot from the first NetBSD
partition it finds (by default).   It is probably clever enough to ignore
bootme flags on non NetBSD partitions.

kre



Re: How to BIOS-boot from NVMe device?

2022-09-08 Thread Paul Goyette

On Thu, 8 Sep 2022, Paul Goyette wrote:


Would be nice to get my menu back and have it default to the NetBSD
system partition, but at least it boots!


I got my menu back.  Just had to put it at /efi/boot.cfg (ie, at the
root of the EFI partition).


++--+--+
| Paul Goyette   | PGP Key fingerprint: | E-mail addresses:|
| (Retired)  | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com|
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org  |
| & Network Engineer |  | pgoyett...@gmail.com |
++--+--+


Re: How to BIOS-boot from NVMe device?

2022-09-08 Thread Paul Goyette

Yay - it boots again!

I re-ran ``gpt biosboot'' and ``installboot'' specifying the NetBSD
partition (index=2), and completely disconnected the hard drives.

It booted!  But I think it is still confused.

The BIOS no longer offers EFI as a boot option.  Yet, the boot menu
I get is the NetBSD flag with no menu options listed.  It simply
declares a default boot file and timeout.  Since the timeout does
not match what I specified in installboot, _and_ the default file
to boot is on device NAME=EFI-system I can only surmise that it did
a EFI-boot.  (The EFI partition is still marked ``bootme''.)

Would be nice to get my menu back and have it default to the NetBSD
system partition, but at least it boots!

Thanks!

PS I _detest_ x86 bootstrap crap!


++--+--+
| Paul Goyette   | PGP Key fingerprint: | E-mail addresses:|
| (Retired)  | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com|
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org  |
| & Network Engineer |  | pgoyett...@gmail.com |
++--+--+


Re: How to BIOS-boot from NVMe device?

2022-09-08 Thread Robert Elz
Date:Wed, 7 Sep 2022 20:37:43 -0700 (PDT)
From:Paul Goyette 
Message-ID:  

  | I tried to run gpt biosboot (and specified -i 1 for the partition)
  | and I also ran installboot.

You didn't show the GPT tables for this system, so "-i 1" means nothing
to anyone but you at the minute, but if we're talking about the same system
as the "nvme hangs" system, then the layout from that on all your nvme
devices had an ESP in the GPT partition with index 1.   (That's kind of
normal, but not required).

If that's what was used, then yes, it would fail spectacularly...

The ESP isn't used for anything at all related to biosboot - nothing,
doesn't need to exist.   Once the system is running, it is a (usually)
smallish FAT formatted partition you can use for anything you like,
though as lon as it retains the ESP GUID in its type field, the BIOS
will keep looking for boot code in there (when it is using UEFI booting).

The biosboot partition is (should be) your NetBSD root.   The thing that
has /boot and /boot.cfg in it.

That's also what you want to use for installboot.

  | On a positive front, the BIOS seems to now recognize the NVMe as
  | having a UEFI OS.

That means that you also did what Michael suggested and copied the EFI
boot program into a boot directory in the ESP.   That's good.

  | Trying to boot it takes me down some new path
  | having to do with SecureBoot, and I don't have time for that now.

I wouldn't even consider trying to make that work.   As Chavdar Ivanov
indicated, it should be possible to disable secure boot in the BIOS
setup.

  | Any suggestions on how to get my legacy boot stuff back?

Two options to proceed - take a step forward, work out how to disable
secure boot in the bios, and continue with the UEFI boot.   That boot
method might, or might not, use your boot.cfg from the root filesystem,
it is more likely to want ESP/NetBSD/boot.cfg (where "ESP" is wherever
you have the ESP mounted, probably /efi from your earlier configs).
Currently I'm unable to make efiboot read boot.cfg from anywhere, it
simply uses its compiled in defaults (boot menu with the NetBSD flag
logo in the banner, which doesn't normally appear in boot.cfg files) -
but my system setup is a bit of a mess.

Alternatively, go back to bios booting, set up the right partition on
the NVME for biosboot (make sure the biosboot attribute is not set on
any partition you don't want to bios boot - which means only have it
set on one, once /boot is loaded from that partition, you can have boot.cfg
(read from the same partition) load the kernel and make the root be anywhere
you like, independently).

kre



Re: How to BIOS-boot from NVMe device?

2022-09-08 Thread Martin Husemann
On Wed, Sep 07, 2022 at 08:37:43PM -0700, Paul Goyette wrote:
> On a positive front, the BIOS seems to now recognize the NVMe as
> having a UEFI OS.  Trying to boot it takes me down some new path
> having to do with SecureBoot, and I don't have time for that now.

There is typicaly a setting in the UEFI to just disable secureboot.

Martin


Re: How to BIOS-boot from NVMe device?

2022-09-07 Thread Paul Goyette

OK, now I _really_ messsed things up, to the point where I have to
write this using the old spinny-rust!  Kernel is at least a month
out of date!

I tried to run gpt biosboot (and specified -i 1 for the partition)
and I also ran installboot.

Result: an unbootable system.  :(  Just goes back to the BIOS boot
page without any messages.

On a positive front, the BIOS seems to now recognize the NVMe as
having a UEFI OS.  Trying to boot it takes me down some new path
having to do with SecureBoot, and I don't have time for that now.

Any suggestions on how to get my legacy boot stuff back?


On Wed, 7 Sep 2022, Paul Goyette wrote:


On Thu, 8 Sep 2022, Robert Elz wrote:


Do you have evidence that the motherboard can boot from nmve at all?
If the motherboard in question is of a similar vintage to those 10 year
old boxes of rust, then it might not be able to, and you might need some
kind of SATA (or perhaps USB) device to boot.


Well, the AMI BIOS talks about UEFI so I just ass-u-me'd ...


 | I'm guessing I need to install some primary boot blocks, but I do
 | not know how to do this for gpt drives (ie, wedges).  I know how to
 | handle on disklabel'd drives, but not gpt.

See the biosboot sub-command in "man gpt", that's all it has ever taken
for me, perhaps along with a suitable installboot (I'm not sure if gpt
installs that one or not, it does install the PMBR boot code).


OK, I apparently tried this a long time ago, and I have a copy of
x86 BIOS Boot from vintage 9.99.82 or so...  :)  With no disks
attached, the system boots that code.  Nothing seems to indicate
that any UEFI boot attempt was made.


Some bios's apparently require the PMBR partition (that is, the protective
MBR partition) to be marked "active" in order to boot from it.


Looks like that was already done, too.


If the BIOS can do UEFI booting, as Michael suggested, (and it works)
then that's a better way.

 | PS I _do_ have a msdos/efi partition on the nvme, but I don't know
 | what to put there!  :)

For BIOS booting it would be irrelevant.


I guess that once I update to newer BIOS Boot, it will process my
boot.cfg file appropriately.


++--+--+
| Paul Goyette   | PGP Key fingerprint: | E-mail addresses:|
| (Retired)  | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com|
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org  |
| & Network Engineer |  | pgoyett...@gmail.com |
++--+--+

!DSPAM:63195ac554638293983044!




++--+--+
| Paul Goyette   | PGP Key fingerprint: | E-mail addresses:|
| (Retired)  | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com|
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org  |
| & Network Engineer |  | pgoyett...@gmail.com |
++--+--+


Re: How to BIOS-boot from NVMe device?

2022-09-07 Thread Paul Goyette

On Thu, 8 Sep 2022, Robert Elz wrote:


Do you have evidence that the motherboard can boot from nmve at all?
If the motherboard in question is of a similar vintage to those 10 year
old boxes of rust, then it might not be able to, and you might need some
kind of SATA (or perhaps USB) device to boot.


Well, the AMI BIOS talks about UEFI so I just ass-u-me'd ...


 | I'm guessing I need to install some primary boot blocks, but I do
 | not know how to do this for gpt drives (ie, wedges).  I know how to
 | handle on disklabel'd drives, but not gpt.

See the biosboot sub-command in "man gpt", that's all it has ever taken
for me, perhaps along with a suitable installboot (I'm not sure if gpt
installs that one or not, it does install the PMBR boot code).


OK, I apparently tried this a long time ago, and I have a copy of
x86 BIOS Boot from vintage 9.99.82 or so...  :)  With no disks
attached, the system boots that code.  Nothing seems to indicate
that any UEFI boot attempt was made.


Some bios's apparently require the PMBR partition (that is, the protective
MBR partition) to be marked "active" in order to boot from it.


Looks like that was already done, too.


If the BIOS can do UEFI booting, as Michael suggested, (and it works)
then that's a better way.

 | PS I _do_ have a msdos/efi partition on the nvme, but I don't know
 | what to put there!  :)

For BIOS booting it would be irrelevant.


I guess that once I update to newer BIOS Boot, it will process my
boot.cfg file appropriately.


++--+--+
| Paul Goyette   | PGP Key fingerprint: | E-mail addresses:|
| (Retired)  | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com|
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org  |
| & Network Engineer |  | pgoyett...@gmail.com |
++--+--+


Re: How to BIOS-boot from NVMe device?

2022-09-07 Thread Robert Elz
Date:Wed, 7 Sep 2022 13:39:08 -0700 (PDT)
From:Paul Goyette 
Message-ID:  

  | I have completely disconnected the wd0 and wd1 hard drives, and now
  | the motherboard/BIOS can't find something (primary boot?).  It does
  | not give any helpful messages (no messages at all), but just goes
  | back to the interactivve BIOS screens.

Do you have evidence that the motherboard can boot from nmve at all?
If the motherboard in question is of a similar vintage to those 10 year
old boxes of rust, then it might not be able to, and you might need some
kind of SATA (or perhaps USB) device to boot.

  | I'm guessing I need to install some primary boot blocks, but I do
  | not know how to do this for gpt drives (ie, wedges).  I know how to
  | handle on disklabel'd drives, but not gpt.

See the biosboot sub-command in "man gpt", that's all it has ever taken
for me, perhaps along with a suitable installboot (I'm not sure if gpt
installs that one or not, it does install the PMBR boot code).

Some bios's apparently require the PMBR partition (that is, the protective
MBR partition) to be marked "active" in order to boot from it.

If the BIOS can do UEFI booting, as Michael suggested, (and it works)
then that's a better way.

  | PS I _do_ have a msdos/efi partition on the nvme, but I don't know
  | what to put there!  :)

For BIOS booting it would be irrelevant.

kre



Re: How to BIOS-boot from NVMe device?

2022-09-07 Thread Paul Goyette

On Wed, 7 Sep 2022, Michael van Elst wrote:


p...@whooppee.com (Paul Goyette) writes:


I have completely disconnected the wd0 and wd1 hard drives, and now
the motherboard/BIOS can't find something (primary boot?).  It does
not give any helpful messages (no messages at all), but just goes
back to the interactivve BIOS screens.


It's likely that the BIOS doesn't know about the NVMe device
and you must use UEFI.



PS I _do_ have a msdos/efi partition on the nvme, but I don't know
what to put there!  :)


You need:

./efi/boot/bootx64.efi

and you may need to tell the machine that it should do an UEFI boot.


Ah, OK.

I did

# mount -t msdos NAME=EFI-system /efi
# cd /efi
# mkdir efi
# mkdir efi/boot
# cp /usr/mdec/bootx64.efi efi/boot/
# cd /
# umount /efi

I'll give a try later, next time i can open up the case.


++--+--+
| Paul Goyette   | PGP Key fingerprint: | E-mail addresses:|
| (Retired)  | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com|
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org  |
| & Network Engineer |  | pgoyett...@gmail.com |
++--+--+


Re: How to BIOS-boot from NVMe device?

2022-09-07 Thread Michael van Elst
p...@whooppee.com (Paul Goyette) writes:

>I have completely disconnected the wd0 and wd1 hard drives, and now
>the motherboard/BIOS can't find something (primary boot?).  It does
>not give any helpful messages (no messages at all), but just goes
>back to the interactivve BIOS screens.

It's likely that the BIOS doesn't know about the NVMe device
and you must use UEFI.


>PS I _do_ have a msdos/efi partition on the nvme, but I don't know
>what to put there!  :)

You need:

./efi/boot/bootx64.efi

and you may need to tell the machine that it should do an UEFI boot.



How to BIOS-boot from NVMe device?

2022-09-07 Thread Paul Goyette

I'm trying desperately to retire my way-too-old spinny-rust, but I
have run into a little problem.

I have completely disconnected the wd0 and wd1 hard drives, and now
the motherboard/BIOS can't find something (primary boot?).  It does
not give any helpful messages (no messages at all), but just goes
back to the interactivve BIOS screens.

I'm guessing I need to install some primary boot blocks, but I do
not know how to do this for gpt drives (ie, wedges).  I know how to
handle on disklabel'd drives, but not gpt.

For now, I have reconnected one of the wd drives and it's working,
but I really don't want to depend on drives that have been running
more-or-less 24x7 for 10+ years!

Thanks in advance for any help!

PS I _do_ have a msdos/efi partition on the nvme, but I don't know
what to put there!  :)


++--+--+
| Paul Goyette   | PGP Key fingerprint: | E-mail addresses:|
| (Retired)  | FA29 0E3B 35AF E8AE 6651 | p...@whooppee.com|
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoye...@netbsd.org  |
| & Network Engineer |  | pgoyett...@gmail.com |
++--+--+