NetBSD Problem Report #55187

From www@netbsd.org  Mon Apr 20 12:50:16 2020
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-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 561191A9213
	for <gnats-bugs@gnats.NetBSD.org>; Mon, 20 Apr 2020 12:50:16 +0000 (UTC)
Message-Id: <20200420125015.41FAB1A924D@mollari.NetBSD.org>
Date: Mon, 20 Apr 2020 12:50:15 +0000 (UTC)
From: isaki@pastel-flower.jp
Reply-To: isaki@pastel-flower.jp
To: gnats-bugs@NetBSD.org
Subject: sysinst partition editor fails on x68k/9.0
X-Send-Pr-Version: www-1.0

>Number:         55187
>Category:       install
>Synopsis:       sysinst partition editor fails on x68k/9.0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    martin
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Apr 20 12:55:00 +0000 2020
>Closed-Date:    Fri Jun 17 15:38:51 +0000 2022
>Last-Modified:  Fri Jun 17 15:38:51 +0000 2022
>Originator:     Tetsuya Isaki
>Release:        NetBSD 9.0
>Organization:
>Environment:
NetBSD 9.0/x68k
>Description:
On 9.0/x68k, sysinst partition editor fails if the target disk
has no Human68k partitions nor BSD disklabels.  Similar PR
(install/54921) which has already been closed is about if the
target disk has Human68k partitions but no BSD disklabels.

>How-To-Repeat:
Initialize harddisk by Human68k genuine FORMAT.X command
(and create no Human68k partitions) beforehand.
That is, there are no Human68k partitions nor BSD disklabels.

Boot from netbsd-9 (or -HEAD) sysinst.

Choose "a: Install NetBSD to hard disk".
Choose "b: Yes".
Choose "a: sd0 (512M)"
Choose "a: Set sizes of NetBSD partitions"
Then it displays the following partition table. (hand-copied)

| You can now change the sizes for the system partitions. ...
|
| Free space will be added to the partition marked with a '+'.
|
|     Size (sec)                            Filesystem
|     ----------------------------------- - --------------
| >a: 622592 (537919487)                  + /
|  b: 0                                     <swap>
|  c: 0                                     /tmp (mfs)
|  d: 0                                     /usr
|  e: 0                                     /var
|     ----------------------------------- - --------------
|  g: Add a user defined partition
|  h: Clone external partition(s)
|  i: Change input units (sectors/cylinders/MB/GB)
|  x: Go on.  Free space 537296895 sec.

As above, the size is strange.
537296895 of free space is 0x20067fff.  I found that this was
calculated by
     0x100000 (from partition[2].size by DIOCGDINFO)
 + 0x1fffffff (from partition[0].size by DIOCGDINFO)
 -    0x98000 (from pset->infos[0].size in bsddisklabel.c).

0x100000 is correct total number of sectors for this disk.  This
diskimage which I used was created by "dd count=512 bs=1m".
0x1fffffff is returned by readdisklabel() in
sys/arch/x68k/x68k/disksubr.c.

sd0 part of dmesg shows:
 sd0: fabricating a geometry
 sd0: 512 MB, 512 cyl, 64 head, 32 sec, 512 bytes/sect x 1048576 sectors
 sd0: async, 8-bit transfer

"disklabel -r sd0" shows:
 disklabel: could not read existing label


By the way, FYI, when I choose (forcely) "x: Go on" in this menu,
it displays following.  And it will naturally fail.

| We now have your disklabel partitions for sd0 below. ...
|
| Flags: (I)nstall, (N)ewfs.  Total size: 512M, free: 0B
|
|     Start (sec)    End (sec)   Size (sec)  FS type Flag Filesystem
|    ------------ ------------ ------------ -------- ---- -----------
| a:            0    536870910    536870911   unused N
| b:            0      1048575      1048576 Whole disk
| c:            0      1048575      1048576   4.2BSD
|    ------------ ------------ ------------ -------- ---- -----------
| e: Change input units (sectors/cylinders/MB/GB)
| f: Edit name fo the disk
| g: Clone external partition(s)
| h: Cancel
|>x: Partition sizes ok


On the other hand, sysinst on netbsd-8 (or before) does as following:

Choose "a: Install NetBSD to hard disk".
Choose "b: Yes".
Choose "a: sd0 (512M, ...)".
Choose "a: Set sizes of NetBSD partitions".
Then,

| You can now change the sizes for the system partitions. ...
|
| Free space will be added to the partition marked with a '+'.
|
|      MB         Cylinders   Sectors   Filesystem
| >a:    146   (383)       146    299008 + /
|  b:    128               128    262144   swap
|  c:      0                 0         0   /tmp (mfs)
|  d:      0                 0         0   /usr
|  e:      0                 0         0   /var
|  f:      0                 0         0   /home
|  g: Add a user defined partition
|  h: Change input units (sectors/cylinders/MB)
|  x: Accept partition sizes.  Free space 237 MB, 5 free partitions.

Even in this case, disklabel (and dmesg) is the same as above.
>Fix:
Sorry, I don't have.

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: install-manager->martin
Responsible-Changed-By: martin@NetBSD.org
Responsible-Changed-When: Mon, 20 Apr 2020 17:26:35 +0000
Responsible-Changed-Why:
take


From: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
To: gnats-bugs@netbsd.org
Cc: tsutsui@ceres.dti.ne.jp
Subject: Re: install/55187: sysinst partition editor fails on x68k/9.0
Date: Sat, 13 Jun 2020 08:51:41 +0900

 This seems to work around the problem.

 Index: disklabel.c
 ===================================================================
 RCS file: /cvsroot/src/usr.sbin/sysinst/disklabel.c,v
 retrieving revision 1.10.2.9
 diff -u -p -d -r1.10.2.9 disklabel.c
 --- disklabel.c	10 Feb 2020 21:39:37 -0000	1.10.2.9
 +++ disklabel.c	12 Jun 2020 23:22:10 -0000
 @@ -265,6 +265,19 @@ disklabel_parts_read(const char *disk, d
  		    && parts->l.d_partitions[part].p_size == 0)
  			continue;

 +		/*
 +		 * Some traditional MD readdisklabel(9) implementation
 +		 * could set p_size = 0x1fffffff for partition a
 +		 * if there is no valid disklabel.
 +		 * Ignore and reset such a bogus partition size.
 +		 */
 +		if (parts->l.d_partitions[part].p_fstype == FS_UNUSED &&
 +		    (parts->l.d_partitions[part].p_size >
 +		     parts->l.d_partitions[RAW_PART].p_size)) {
 +			parts->l.d_partitions[part].p_size = 0;
 +			continue;
 +		}
 +
  		parts->dp.num_part++;
  		if (parts->l.d_partitions[part].p_fstype == FS_UNUSED)
  			continue;

 ---

 c.f.
  http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/arch/i386/i386/Attic/disksubr.c?annotate=1.4

 ---
 % grep '\[0\].*0x1fffffff' sys/arch/*/*/disksubr.c 
 sys/arch/pmax/pmax/disksubr.c:		lp->d_partitions[0].p_size = 0x1fffffff;
 sys/arch/x68k/x68k/disksubr.c:		lp->d_partitions[0].p_size = 0x1fffffff;
 ---

 Maybe we should also check explicit (p_size == 0x1fffffff)
 for possible larger disks?

 Note size of swap partition is set to zero due to
 PR/55375 because size of the target disk is
 512MB (smaller than DEFUSRSIZE (1024MB)).

 ---
 Izumi Tsutsui

From: "Izumi Tsutsui" <tsutsui@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55187 CVS commit: src/sys/arch/x68k/x68k
Date: Thu, 18 Jun 2020 19:54:08 +0000

 Module Name:	src
 Committed By:	tsutsui
 Date:		Thu Jun 18 19:54:08 UTC 2020

 Modified Files:
 	src/sys/arch/x68k/x68k: disksubr.c

 Log Message:
 Use a sane default for size of partition a: rather than odd 0x1fffffff.

 The latter one seems derived from 386BSD (and 4.4BSD),
 but it could confuse sysinst as noted in PR/55187.
 Sync with most other modern ports that use secperunit
 as well as RAW_PART.


 To generate a diff of this commit:
 cvs rdiff -u -r1.35 -r1.36 src/sys/arch/x68k/x68k/disksubr.c

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

From: "Martin Husemann" <martin@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/55187 CVS commit: [netbsd-9] src/sys/arch/x68k/x68k
Date: Tue, 30 Jun 2020 18:20:54 +0000

 Module Name:	src
 Committed By:	martin
 Date:		Tue Jun 30 18:20:54 UTC 2020

 Modified Files:
 	src/sys/arch/x68k/x68k [netbsd-9]: disksubr.c

 Log Message:
 Pull up following revision(s) (requested by tsutsui in ticket #973):

 	sys/arch/x68k/x68k/disksubr.c: revision 1.36

 Use a sane default for size of partition a: rather than odd 0x1fffffff.

 The latter one seems derived from 386BSD (and 4.4BSD),
 but it could confuse sysinst as noted in PR/55187.

 Sync with most other modern ports that use secperunit
 as well as RAW_PART.


 To generate a diff of this commit:
 cvs rdiff -u -r1.35 -r1.35.4.1 src/sys/arch/x68k/x68k/disksubr.c

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

State-Changed-From-To: open->closed
State-Changed-By: tsutsui@NetBSD.org
State-Changed-When: Fri, 17 Jun 2022 15:38:51 +0000
State-Changed-Why:
Superseded by PR install/56890 (caused by the default labgel by readdisklabel(9).


>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.