NetBSD Problem Report #55894

From bsiegert@netbsd.org  Fri Dec 25 12:32:52 2020
Return-Path: <bsiegert@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 15A851A921F
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 25 Dec 2020 12:32:52 +0000 (UTC)
Message-Id: <20201225123250.A14AE1A923A@mollari.NetBSD.org>
Date: Fri, 25 Dec 2020 12:32:50 +0000 (UTC)
From: bsiegert@netbsd.org
Reply-To: bsiegert@netbsd.org
To: gnats-bugs@NetBSD.org
Subject: installboot overwrites primary GPT
X-Send-Pr-Version: 3.95

>Number:         55894
>Category:       port-evbarm
>Synopsis:       installboot overwrites primary GPT
>Confidential:   no
>Severity:       critical
>Priority:       medium
>Responsible:    port-evbarm-maintainer
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 25 12:35:00 +0000 2020
>Closed-Date:    Sun Mar 07 19:52:56 +0000 2021
>Last-Modified:  Sun Mar 07 19:52:56 +0000 2021
>Originator:     Benny Siegert
>Release:        NetBSD 9.99.74
>Organization:
The NetBSD Foundation
>Environment:
NetBSD 9.99.74 with an older -current userland.
Pine A64-LTS, running evbarm-aarch64.
>Description:
I added an eMMC module to the Pine A64 and have been trying to transfer
my existing NetBSD installation over from the SD card. The part where
things go wrong is when installing U-Boot.

I created a GPT with an EFI partition, a root and swap partition.
I first tried to install the bootloader with the following command that
I found on the wiki:

dd if=u-boot-sunxi-with-spl.bin of=/dev/rld1c bs=1k seek=1 conv=sync

However, that overwrites the primary GPT, since the GPT extends beyond
the 8 KB skipped.

Next (after "gpt recover"), I tried using installboot:

installboot -v ld1

The -v parameter produces so much output that I did not quite see what
actually happened. However, the GPT (primary copy) is also overwritten
by installboot.

At reboot, you can see U-Boot come up over the serial console and then
fail to find any partitions.
>How-To-Repeat:
installboot -v ld1
reboot
>Fix:
I don't know, however I would very much like to be able to boot from the
eMMC drive with GPT :)

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: port-evbarm/55894: installboot overwrites primary GPT
Date: Fri, 25 Dec 2020 13:50:04 +0100

 On Fri, Dec 25, 2020 at 12:35:00PM +0000, bsiegert@netbsd.org wrote:
 > I created a GPT with an EFI partition, a root and swap partition.

 How exactly did you do that?

 You will need to use "gpt create -p $N" to restrict the space for the GPT
 so firmware does not collide.

 Sysinst sets MD_GPT_INITIAL_SIZE to 8k for this and then calcultes
 $N as ((MD_GPT_INITIAL_SIZE-(2*512))/512)*GPT_PARTS_PER_SEC

 where GPT_PARTS_PER_SEC is 4 (that is: four GPT entries fit in 512 bytes)

 which should be 56 if my math is correct.

 Martin

State-Changed-From-To: open->closed
State-Changed-By: bsiegert@NetBSD.org
State-Changed-When: Sun, 07 Mar 2021 19:52:56 +0000
State-Changed-Why:
Specifying the maximum number of entries did the trick.
Thank you very much!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.