NetBSD Problem Report #57025

From tsutsui@ceres.dti.ne.jp  Sun Sep 25 07:57:22 2022
Return-Path: <tsutsui@ceres.dti.ne.jp>
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 7B4321A921F
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 25 Sep 2022 07:57:22 +0000 (UTC)
Message-Id: <202209250757.28P7vCXK028078@ceres.dti.ne.jp>
Date: Sun, 25 Sep 2022 16:57:12 +0900 (JST)
From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
Reply-To: tsutsui@ceres.dti.ne.jp
To: gnats-bugs@NetBSD.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: landisk sysinst should not installboot against RAWPART
X-Send-Pr-Version: 3.95

>Number:         57025
>Category:       install
>Synopsis:       landisk sysinst should not installboot against RAWPART
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    martin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 25 08:00:00 +0000 2022
>Closed-Date:    Thu Dec 29 20:59:05 +0000 2022
>Last-Modified:  Thu Dec 29 20:59:05 +0000 2022
>Originator:     Izumi Tsutsui
>Release:        NetBSD 9.3
>Organization:
>Environment:
System: NetBSD lantank 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug  4 15:30:37 UTC 2022  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/landisk/compile/GENERIC landisk
Architecture: sh3el
Machine: landisk
>Description:
Since NetBSD 9.0 and later, sysinst for landisk exec installboot
against RAWPART:

>> revision 1.9
>> date: 2019-06-22 01:57:12 +0900;  author: martin;  state: Exp;  lines: +2 -2;  commitid: kB4u7bjwl623R4sB;
>> Use the raw partition for installboot, not the root partition.

I'm not sure why this change was necessary, but sysinst 8.x and prior
installed /usr/mdec/mbr by fdisk(8) as the first loader as x86 and
bootxx_ffsvX is installed to the NetBSD partition, i.e. a partition a.

Then installboot(8) against RAWPART during upgrading to NetBSD 9.x
breaks existing bootstrap.

>How-To-Repeat:
Install NetBSD/landisk 8.x (via ustarfs install image)
and upgrade to NetBSD 9.x via sysinst.

The upgrade installation works but fails to boot:

---
SH IPL+g version 0.9, Copyright (C) 2000 Free Software Foundation, Inc.

This software comes with ABSOLUTELY NO WARRANTY; for details type `w'.
This is free software, and you are welcome to redistribute it under
certain conditions; type `l' for details.

2002/09/09 Making.  2003/10/16 I-O DATA NSD NWG Update.
266:133:33 on base clock 22.22MHz and SDRAM 4 burst. ATA boot.

A-Card ATP865 ATA controller found.
PCIC initialization done.
MASTER:48bit LBA mode support
Disk drive detected: ADATA SP310 2.3 2D3220001026 
LBA: 07740AB0
DiskSize: 64GByte
PIO MODE1
Set Transfer Mode result: 50 
A-Card ATP865 ATA controller found.
> b
Set Transfer Mode result: 50 
Initialize Device Parameters result: 50 
IDLE result: 50 

NetBSD/landisk ffsv1 Primary Bootstrap
Error: Can't open /boot.


---

That should be (i.e. /usr/mdec/mbr in the sector zero loads bootxx_ffsvX
at the top of the NetBSD partition):
---
 :

A-Card ATP865 ATA controller found.
> b
Set Transfer Mode result: 50 
Initialize Device Parameters result: 50 
IDLE result: 50 

NetBSD MBR boot

NetBSD/landisk ffsv1 Primary Bootstrap

>> NetBSD/landisk Boot, Revision 1.0 (Thu Aug  4 15:30:37 UTC 2022)
Press return to boot now, any other key for boot menu
booting hd0a:netbsd - starting in 0 
type "?" or "help" for help.
> 
---

>Fix:
Revert src/usr.sbin/sysinst/arch/landisk/md.c rev 1.9 and
install /usr/mdec/mbr via fdisk(8) as i386/amd64 ports?

At least, it should check if the target disk has a vaild fdisk partition
on upgrade.

---
Izumi Tsutsui

>Release-Note:

>Audit-Trail:
From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: install/57025: landisk sysinst should not installboot against
 RAWPART
Date: Sun, 25 Sep 2022 11:22:57 +0200

 On Sun, Sep 25, 2022 at 08:00:00AM +0000, Izumi Tsutsui wrote:
 > Revert src/usr.sbin/sysinst/arch/landisk/md.c rev 1.9 and
 > install /usr/mdec/mbr via fdisk(8) as i386/amd64 ports?
 > 
 > At least, it should check if the target disk has a vaild fdisk partition
 > on upgrade.

 It needs to check for that - I have a landisk installation w/o MBR
 (and wasn't aware this is unusual).

 Martin

From: Martin Husemann <martin@duskware.de>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: install/57025: landisk sysinst should not installboot against
 RAWPART
Date: Sun, 25 Sep 2022 14:08:04 +0200

 I was wrong - I do have a MBR:

 Disk: /dev/rwd0
 NetBSD disklabel disk geometry:
 cylinders: 15538, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
 total sectors: 15662304, bytes/sector: 512

 BIOS disk geometry:
 cylinders: 975, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
 total sectors: 15662304

 Partitions aligned to 16065 sector boundaries, offset 63

 Partition table:
 0: NetBSD (sysid 169)
     start 64, size 15662240 (7648 MB, Cyls 0/1/2-974/237/63), Active
         PBR is not bootable: Bad magic number (0xaed4)
 1: <UNUSED>
 2: <UNUSED>
 3: <UNUSED>
 First active partition: 0
 Drive serial number: 0 (0x00000000)


 and disklabel agrees (wd0c == MBR partition 0):

 4 partitions:
 #        size    offset     fstype [fsize bsize cpg/sgs]
  a:  15137952        64     4.2BSD      0     0     0  # (Cyl.      0*-    942*)
  b:    524256  15138048       swap                     # (Cyl.    942*-    974*)
  c:  15662240        64     unused      0     0        # (Cyl.      0*-    974*)
  d:  15662304         0     unused      0     0        # (Cyl.      0 -    974*)


 ... but I don't get any message from the MBR bootsector:

 DiskSize: 3724132352Byte
 PIO MODE1
 Set Transfer Mode result: 50 
 > b
 Set Transfer Mode result: 50 
 Initialize Device Parameters result: 50 
 IDLE result: 50 
 NetBSD/landisk ffsv1 Primary Bootstrap

 >> NetBSD/landisk Boot, Revision 1.0 (Fri Dec 20 11:46:58 UTC 2019)
 Press return to boot now, any other key for boot menu
 booting hd0a:netbsd - starting in 0 
 4626928+117708 [308944+297777]=0x51ac10
 Start @ 0x8c001000 [1=0x8c4875bc-0x8c51bc10]...
 [   1.0000000] Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
 [   1.0000000]     2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017,
 [   1.0000000]     2018, 2019, 2020, 2021, 2022
 [   1.0000000]     The NetBSD Foundation, Inc.  All rights reserved.
 [   1.0000000] Copyright (c) 1982, 1986, 1989, 1991, 1993
 [   1.0000000]     The Regents of the University of California.  All rights reserved.
 [   1.0000000] NetBSD 9.99.100 (GENERIC) #191: Tue Sep 20 12:54:04 CEST 2022
 [   1.0000000]  martin@seven-days-to-the-wolves.aprisoft.de:/work/src/sys/arch/landisk/compile/GENERIC
 [   1.0000000] Model: I-O DATA LANDISK
 [   1.0000000] total memory = 65536 KB
 [   1.0000000] avail memory = 59264 KB
 [   1.0000000] mainbus0 (root)

 So apparently I don't have /usr/mdec/mbr installed and that is why I
 needed to use the raw partition (starting at the first sector) for
 installboot. I must have missed a step in the install docs.

 Martin

From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: martin@duskware.de, tsutsui@ceres.dti.ne.jp
Subject: Re: install/57025: landisk sysinst should not installboot againstRAWPART
Date: Sun, 25 Sep 2022 23:54:03 +0900

 Mine has:

 ---
 # disklabel wd0
 # /dev/rwd0:
 type: SCSI
 disk: 310             
 label: fictitious
 flags:
 bytes/sector: 512
 sectors/track: 63
 tracks/cylinder: 16
 sectors/cylinder: 1008
 cylinders: 16383
 total sectors: 125045424
 rpm: 3600
 interleave: 1
 trackskew: 0
 cylinderskew: 0
 headswitch: 0           # microseconds
 track-to-track seek: 0  # microseconds
 drivedata: 0 

  partitions:
 #        size    offset     fstype [fsize bsize cpg/sgs]
  a: 122939392      8192     4.2BSD   4096 16384    64  # (Cyl.      8*- 121971*)
  b:   2097840 122947584       swap                     # (Cyl. 121971*- 124052)
  c: 125037232      8192     unused      0     0        # (Cyl.      8*- 124052)
  d: 125045424         0     unused      0     0        # (Cyl.      0 - 124052)
 # fdisk wd0
 fdisk: Cannot determine the number of heads
 Disk: /dev/rwd0
 NetBSD disklabel disk geometry:
 cylinders: 124053, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
 total sectors: 125045424, bytes/sector: 512

 BIOS disk geometry:
 cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
 total sectors: 125045424

 Partitions aligned to 16065 sector boundaries, offset 63

 Partition table:
 0: NetBSD (sysid 169)
     start 8192, size 125037232 (61053 MB, Cyls 0/130/3-7783/182/63), Active
 1: <UNUSED>
 2: <UNUSED>
 3: <UNUSED>
 First active partition: 0
 Drive serial number: 0 (0x00000000)
 # 
 ---

 Note old sysinst installs /usr/mdec/mbr:
  https://github.com/NetBSD/src/blob/netbsd-8/usr.sbin/sysinst/arch/landisk/md.c#L95

 ---
 Izumi Tsutsui

Responsible-Changed-From-To: install-manager->martin
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Sun, 02 Oct 2022 10:24:23 +0000
Responsible-Changed-Why:
My bug


State-Changed-From-To: open->pending-pullups
State-Changed-By: martin@NetBSD.org
State-Changed-When: Sun, 02 Oct 2022 10:24:23 +0000
State-Changed-Why:
[pullup-9 #1535]


From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57025 CVS commit: src/usr.sbin/sysinst/arch/landisk
Date: Sun, 2 Oct 2022 10:21:36 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Sun Oct  2 10:21:36 UTC 2022

 Modified Files:
 	src/usr.sbin/sysinst/arch/landisk: md.c

 Log Message:
 PR install/57025: revert bogus rev 1.9 which was only papering over
 a bug in the adoption of the MBR handling code and fix the original
 conversion bug instead:
  - run fdisk to install the MBR bootcode on the raw disk partition
  - run installboot against the NetBSD root partition (not the raw partition).


 To generate a diff of this commit:
 cvs rdiff -u -r1.15 -r1.16 src/usr.sbin/sysinst/arch/landisk/md.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: "Soren Jacobsen" <snj@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/57025 CVS commit: [netbsd-9] src/usr.sbin/sysinst/arch/landisk
Date: Tue, 4 Oct 2022 17:14:08 +0000

 Module Name:	src
 Committed By:	snj
 Date:		Tue Oct  4 17:14:08 UTC 2022

 Modified Files:
 	src/usr.sbin/sysinst/arch/landisk [netbsd-9]: md.c

 Log Message:
 Pull up following revision(s) (requested by martin in ticket #1535):
 	usr.sbin/sysinst/arch/landisk/md.c: revision 1.16
 PR install/57025: revert bogus rev 1.9 which was only papering over
 a bug in the adoption of the MBR handling code and fix the original
 conversion bug instead:
  - run fdisk to install the MBR bootcode on the raw disk partition
  - run installboot against the NetBSD root partition (not the raw partition).


 To generate a diff of this commit:
 cvs rdiff -u -r1.10.2.4 -r1.10.2.5 src/usr.sbin/sysinst/arch/landisk/md.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

State-Changed-From-To: pending-pullups->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Thu, 29 Dec 2022 20:59:05 +0000
State-Changed-Why:
pulled up


>Unformatted:

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-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.