NetBSD-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: EFI amd64: boot.cfg goes where?



    Date:        Wed, 05 Aug 2026 16:34:33 -0600
    From:        "DTB" <trinity@tebibyte.media>
    Message-ID:  <DKHD9PJ7LC5K.2V87UAHGZOWQP@tebibyte.media>

  | I then tried:
  |
  | # gpt show -a wd0

Yes, that way works, so would "gpt show -i 4 wd0" (for any partition
index of interest).   (You could also use -b specifying the starting
block number, but except for things like gaps, and headers, which have
no index, why would you?   None of those other things have attributes.)

  | I fixed that like so:
  | # gpt unset -i 1 -a bootme wd0

That was definitely the thing to do.

  | And now my system boots successfully!

Good.

  | I am a little curious as to how my NetBSD rootfs at GPT
  | partition 4 is called hd0d by the booter

Is it?   You shouldn't care, don't use those kinds of names when
booting from GPT.   Instead use the NAME=label syntax (but beware,
for NetBSD currently, the total length of the "NAME=label" for the
root/boot filesystem (and only that one) is 16 bytes (I think 15 useful
ones, plus a \0).   Since "NAME=" consumes 5 of those, the label for
the NetBSD root filesystem needs to be 10 bytes, or less (labels are
actually UTF-8 strings (except for in the GPT label itself, where they are
UCS-2 (more or less UTF-16) but that's of no concern to almost anything),
so one character, if it isn't ascii, can use 2 3 or 4 bytes).

show -a or show -l will show the labels, as will -i or -b for a single
partition.

You can use NAME= when specifying the root, and when specifying from
where to boot, though generally (unless they are to differ) you only
really need to set one of them (set root to be NAME=NETBSD and you can
just "boot netbsd [-s]..." or you can "boot NAME=NETBSD:netbsd [-s]..." and
not bother setting root at all.   Note that while GPT labels can contain
almost any characters you can imagine, don't try to use ':' or (if going
to be in fstab anywhere, any kind of whitespace, incl \n) I'd also avoid
'=' '\' '$' and anything else that might have some other meaning (quote
chars, etc).

  | as I thought hd0d would be the third partition; it goes hd0a, hd0b,
  | and then hd0c is the whole drive, right?

Frankly, I have no idea how those hdNx labels are assigned, or what
they mean.   Just don't use them, anywhere (with efiboot).   As a guess
though, I'd assume that it might be just a==1 b==2 c==3 d==4 ... (where
the number is the GPT partition index) - your NetBSD partition is index 4,
so 'd'.   A note to everyone reading this - this is just speculation, not
any kind of auth info, unless someone who actually knows (not just thinks)
replies and says it is correct.   If someone says it is incorrect, believe
them, not me!

When using gpt, there is no concept at all of the "whole device" when
referring to partitions, GPT partitions are not allowed to overlap each
other (unlike disklabel partitions), so you cannot have a partition, and
something such as the "whole device", as they would have blocks in common.

When you need the device, rather than a partition, use the wdN name instead.
(just /dev/wd0 or /dev/rwd0 etc - no partition letter at all).   (And just
the same if the device is sdN ldN raidN ccdN cgdN ...).

In old disklabel days, on x86 systems, wd0c was traditionally the whole
NetBSD MBR partition, and wd0d was the whole drive.   On other ports, with
no MBR, and hence no need to refer to the NetBSD MBR partition, wd0c is
the whole drive, and wd0d is just some other partition - the latter was how
traditional BSD (as in from Berkeley) worked on a vax, and I assume mips as
well.   Using the names that have no partition letter allows you to avoid
caring about that distinction (wd0 will be the same thing as either wd0c
or wd0d depending upon which of them means "whole drive" for the port in
question).   Never refer (inside NetBSD) to anything other than the whole
drive when the drive has GPT partitions.   Use the wedge names (dkN) or
the NAME=label syntax, supported by most things which access disks, instead.

kre




Home | Main Index | Thread Index | Old Index