NetBSD Problem Report #59484

From www@netbsd.org  Tue Jun 24 22:46:38 2025
Return-Path: <www@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)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 0FCD41A9239
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 24 Jun 2025 22:46:38 +0000 (UTC)
Message-Id: <20250624224636.7EE4C1A923A@mollari.NetBSD.org>
Date: Tue, 24 Jun 2025 22:46:36 +0000 (UTC)
From: uwe@stderr.spb.ru
Reply-To: uwe@stderr.spb.ru
To: gnats-bugs@NetBSD.org
Subject: sysinst is confused by hybrid MBR
X-Send-Pr-Version: www-1.0

>Number:         59484
>Category:       install
>Synopsis:       sysinst is confused by hybrid MBR
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    install-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Jun 24 22:50:00 +0000 2025
>Last-Modified:  Thu Jun 26 01:35:00 +0000 2025
>Originator:     Valery Ushakov
>Release:        NetBSD 10.1
>Organization:
>Environment:
>Description:
sysinst on x86 unconditionally calls `gpt biosboot` in
md_gpt_post_write(), but gpt(8) seems to be confused and unhappy about
hybrid MBR.  So if you a trying to install NetBSD on such a disk, the
installation fails after partitioning with

   Status: Command failed
  Command: gpt biosboot -b 0123456789

and no further details that provide a clue as to what went wrong.

>How-To-Repeat:
Try to install NetBSD on a disk that already has a Linux on it, to
dual boot.  My scenario was:

1) Install Ubuntu, erasing the disk and using the whole disk (yes, I
   was lazy :).

   That actually creates GPT partition with the normal protective MBR.

2) Use gparted to reduce the size of the Linux partition and to pre
   create GPT partitions for NetBSD in a nice point-and-click
   partition editor (did I mention I was lazy?).

   This is where it seems to go wrong.  gparted as shipped with the
   Ubuntu 24.04 install/live image makes the disk switch to hybrid MBR

3) Try to install NetBSD on that same disk.  Observe installation fail
   immediately after you configure it to use existing partitions and
   start the actual installation.

>Fix:
You can boot with a Linux live image and re-create protective MBR with

  # gdisk /dev/...
  x
  n
  w

where `x` switches to the expert mode, `n` recreates the protective
MBR, and `w` writes back the changes.

Looking at the manual page, I guess sysinst should probably invoke
gpt(8) with `-H` for that `biosboot` to ignore hybrid MBR (haven't
tried it myself, dunno, if it would be enough).

May be teach gpt(8) to re-create protective MBR?  Though that
probably requires additional interaction with the user.

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: install/59484: sysinst is confused by hybrid MBR
Date: Wed, 25 Jun 2025 08:05:20 +0200

 On Tue, Jun 24, 2025 at 10:50:00PM +0000, uwe@stderr.spb.ru wrote:
 > 2) Use gparted to reduce the size of the Linux partition and to pre
 >    create GPT partitions for NetBSD in a nice point-and-click
 >    partition editor (did I mention I was lazy?).

 At this point you could use the already existing partitions and point
 sysinst at them. In the "Available disks" menu near the end, before
 "Extended partitioning" you should see a menu item

 	Preconfigured "wedges" dk(4)

 and if the GPT partitions had the right GUIDs it would even recognize a
 swap partition next to a NetBSD ffs partition.

 Could you upload a smallish/compressed disk image with a hybrid GPT
 somewhere, please?

 Martin

From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@netbsd.org
Cc: Martin Husemann <martin@duskware.de>
Subject: Re: install/59484: sysinst is confused by hybrid MBR
Date: Thu, 26 Jun 2025 04:34:06 +0300

 > Could you upload a smallish/compressed disk image with a hybrid GPT
 > somewhere, please?

 I tried but a naive attempt didn't work.  May be it needs the EFI
 partition or something.  It might be easier for you to reproduce it
 locally in a VM by following the steps I described.  You might be able
 to skip the longest first step (installing linux) by grabbing some
 existing Ubuntu OVA e.g. https://www.osboxes.org/ubuntu/

 Alternatively, gdisk can convert from protective MBR to hybrid MBR
 (and vice versa, which I did) https://www.rodsbooks.com/gdisk/

 I'll try to see if I can reproduce this over the weekend when I have
 more time.

 I think it's worthwhile to make the dual boot scenario of 1) reduce
 existing linux partition, 2) install netbsd into the freed space - a
 bit smoother (if the user is committed enough to run NetBSD on real
 h/w and not in the VM, it should be encouraged :).

 -uwe

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2025 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.