Monday, December 27, 2021

Re: Disk partition not recognized

On Sat, Dec 25, 2021 at 8:46 AM Crystal Kolipe <kolipe.c@exoticsilicon.com>
wrote:

> OK, the issue lies with the four byte checksum at offset 0x58 in sector 1.
>
> Testing on OpenBSD 7.0 release and using your GPT:
>
> The kernel enters spoofgptlabel and reads sector 1.
>
> When we call gpt_chk_parts, the calculated checksum comes to 0x0BE89E52,
> whereas the on-disk checksum is 0x3F7A886C, as you can see in the hexdumps.
>
> Note that the on-disk checksum is stored in little-endian format.
>
> As a result, gpt_chk_parts returns EINVAL. When control returns to
> spoofgptlabel, it doesn't read the partitions contained within, and goes on
> to try to read the second GPT at sector dsize-1, which in your case is
> sector 9767541167.
>
> That's the reason why you don't see the non-OpenBSD partitions in your,
> (spoofed), disklabel, the on-disk checksum of the partition entries does
> not match the calculated checksum, so the kernel considers the GPT to be
> invalid.
>
> If you want to test removing the call to gpt_chk_parts, thereby forcing
> the kernel to parse whatever it finds and ignoring any checksum errors, the
> attached diffs should allow you to do that. As you said that you were
> still running OpenBSD 6.9, I've produced a diff against that too, including
> the change in line 609 that I mentioned earlier, but it's untested. There
> were other changes to this code between 6.9 and 7.0 that I have not really
> looked at.
>
> On OpenBSD 7.0, with the diff applied, I am able to parse the GPT that you
> supplied.
>
> I doubt that a kernel option to disable the checksum verification would be
> appropriate or welcome, but I don't know how common the problem is.
>

Thanks for the work tracking down the problems. I reformatted the hard
drive to see if that would do anything and then I installed OpenBSD 7.0
like you suggested and it started working. I used Disk Utility in MacOS
10.15.7 Catalina, and when I reformatted it I got some errors from Disk
Utility. My guess is that Disk Utility is doing something incorrectly.

No comments:

Post a Comment