Re: [Gptfdisk-general] misreads NetBSD as FreeBSD
Brought to you by:
srs5694
|
From: David C. <dav...@gm...> - 2023-08-03 23:58:52
|
On 8/3/23 6:59 AM, Rod Smith wrote:
> On 8/3/23 04:31, dch...@gm... wrote:
>> Lately I also use gdisk, etc. Unlike fdisk, gdisk misreads my NetBSD
>> partition as a FreeBSD one.
>
> There's a lot you haven't stated that's likely relevant. For instance,
> is the disk currently MBR or GPT? If the latter, was it once MBR, but
> was converted to GPT; and if so, by what program? Is the fdisk you're
> using from util-linux or based on libparted? What column(s) of output
> are you reading in both fdisk and gdisk? Because I don't know the
> answers to these questions, I can't give you an answer about what's
> going on; however, I can say this....
I guess everything's fine then. The solid state drive (SSD/M2/NVME) is
currently MBR and I used fdisk from util-linux but also used it on *BSD
UNIX (which works differently).
> On an MBR disk, FreeBSD and NetBSD can use the same partition type
> code (0xA5), although NetBSD also has its own code (0xA9)[1]; however,
> on a GPT disk, the two OSes each have their own set of unique
> GUIDs[2]. That said, the MBR 0xA5 and 0xA9 codes are both most often
> used for a BSD "disklabel," which holds sub-partitions, similar to an
> MBR extended partition. Among the GPT type codes, AFAIK only FreeBSD's
> set includes an explicit "disklabel" partition
> (516E7CB4-6ECF-11D6-8FF8-00022D09712B); AFAIK, there is no NetBSD
> equivalent to this in GPT. Because GPT fdisk does an automatic
> conversion from MBR to GPT, when you read an MBR disk with a NetBSD
> 0xA5 partition with GPT fdisk, that partition will show up as a
> FreeBSD partition, since 0xA5 is more strongly associated with FreeBSD
> than with NetBSD. Also, in GPT fdisk, most a9xx codes get converted to
> unique NetBSD codes; however, a900 (or 0xA9, when reading an MBR disk)
> gets converted to 516E7CB4-6ECF-11D6-8FF8-00022D09712B, the FreeBSD
> disklabel code, since the GPT type code list on Wikipedia[2] doesn't
> specify a unique NetBSD disklabel type code, and I don't see anything
> labeled as a "disklabel" code in the relevant NetBSD source code
> file[3], either.
I specficially set the NetBSD partition to a9 but saw gdisk list the
*BSD partitions (except DragonFlyBSD) as A500.
> It's possible that what you're seeing is a result of this, either on
> an MBR disk or a disk converted to GPT from MBR. An fdisk that's based
> on libparted, by contrast, would read the contents of the partition
> and present a filesystem type rather than present the type code
> itself; and util-linux fdisk would present the type code for an MBR
> partition, rather than try to convert it to GPT, as GPT fdisk does.
>
> If the disk was partitioned initially as a GPT disk, then I'd expect
> that NetBSD's partitions should use native NetBSD type codes, which
> GPT fdisk presents as a901 through a906. If one of the partitions hold
> an old-style BSD "disklabel," then AFAIK there's no NetBSD-specific
> GPT type code for that, so the best choice for the GPT partition type
> code would be 516E7CB4-6ECF-11D6-8FF8-00022D09712B, which is
> officially a FreeBSD type code, and is presented as such by both GPT
> fdisk and util-linux fdisk. (I don't know offhand how a
> libparted-based fdisk presents such a partition, if it's created in
> NetBSD.)
>
> One more factor: The GPT fdisk output includes the partition name. If
> the partition is created in gdisk, then gdisk sets this name to a
> description that's tied to the type code, by default. For instance:
>
> Number Start (sector) End (sector) Size Code Name
> 1 2048 30296063 14.4 GiB A500 FreeBSD
> disklabel
>
> (That's two lines; the second one will likely wrap in this e-mail.)
>
> If the type code is changed outside of GPT fdisk, the name may not be
> updated. For instance, taking the above disk and changing the type
> code in util-linux's fdisk to fdisk's 79 ("NetBSD FFS") results in it
> looking like this in GPT fdisk:
>
> Number Start (sector) End (sector) Size Code Name
> 1 2048 30296063 14.4 GiB A902 FreeBSD
> disklabel
>
> Note that the type code has changed from A500 to A902, but the
> partition's name remains "FreeBSD disklabel," although that's no
> longer accurate. This is another strong possibility for what you're
> seeing. If so, the solution is simply to update the partition's name
> in GPT fdisk to something appropriate. This can be done with the "c"
> main-menu option in gdisk. Note that util-linux fdisk does not present
> the partition name in its main summary, although the information is
> available via the "i" main-menu option.
>
> [1] https://www.win.tue.nl/~aeb/partitions/partition_types-1.html
> [2] https://en.wikipedia.org/wiki/GUID_Partition_Table
> [3]
> http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/sys/disklabel_gpt.h?rev=1.15&content-type=text/x-cvsweb-markup&f=h&only_with_tag=MAIN
Thanks. I'd more likely reinstall everything on that drive if I had a
reason to convert to GPT, but I aliased fdisk to gdisk because when I
got two new 16TB WD/HGST hard disc drives and used fdisk on them, it
seemed they were broken, and I didn't want to accidentally try a third.
Likely it wasn't fdisk causing it rather than just some decrease in
quality and a chance I got two bad ones. However now I type fdisk
(gdisk) or /sbin/fdisk (the real fdisk).
|