Subject: bin/7446: disklabel -w -r rejects automatically generated label when formatted as a disktab entry
To: None <>
From: Matthias Buelow <>
List: netbsd-bugs
Date: 04/22/1999 16:53:08
>Number:         7446
>Category:       bin
>Synopsis:       disklabel -w -r rejects automatically generated label when formatted as a disktab entry
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Apr 22 16:20:01 1999
>Originator:     Matthias Buelow
   Matthias Buelow, Wuerzburg/Germany,
>Release:        1.4_ALPHA as of April 14th 1999
System: NetBSD 1.4_ALPHA NetBSD 1.4_ALPHA (ALTAIR) #1: Mon Apr 19 01:22:12 CEST 1999 i386

For installing new scsi disks without a BSD disk pack label on them,
I dumped the kernel-generated label with disklabel -t to a file in
disktab format and then wanted to write the label to disk with
disklabel -w -r -f.  Disklabel complains about partitions extending
past the end of unit and refused to write the label.

The following script illustrates the problem (note however, that this
is not the kernel generated label but the on-disk label, since I have
managed to write a label in a different way and added partitions since
then but it doesn't make a difference to the problem in discussion since
the geometry is the same as in the original label).

# disklabel -t sd1
DCAS-34330W|Automatically generated label:\
# disklabel -t sd1 > label
# disklabel -w -r -f label sd1 DCAS-34330W
disklabel: partition d: partition extends past end of unit
disklabel: partition e: partition extends past end of unit

In plaintext:

# disklabel sd1
# /dev/rsd1d:
type: SCSI
disk: DCAS-34330W
label: mkb-sd1
bytes/sector: 512
sectors/track: 171
tracks/cylinder: 6
sectors/cylinder: 1026
cylinders: 8205
total sectors: 8467200
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0           # milliseconds
track-to-track seek: 0  # milliseconds
drivedata: 0 

5 partitions:
#        size   offset     fstype   [fsize bsize   cpg]
  b:   262144        0       swap                        # (Cyl.    0 - 255*)
  d:  8467200        0     unused        0     0         # (Cyl.    0 - 8252*)
  e:  8205056   262144     4.2BSD     1024  8192    16   # (Cyl.  255*- 8252*)

Writing back this (more verbose) plain text label works.

The relevant lines about disk capacity from kernel output at boot time
(using the ncr driver):

sd1 at scsibus0 targ 1 lun 0: <IBM, DCAS-34330W, S61A> SCSI2 0/direct fixed
sd1(ncr0:1:0): WIDE SCSI (16 bit) enabled
sd1(ncr0:1:0): 40.0 MB/s (50 ns, offset 15)
sd1: 4134MB, 8205 cyl, 6 head, 171 sec, 512 bytes/sect x 8467200 sectors

Dump the disklabel with kernel generated geometry values to a file in
disktab format and then try to write it to the disk.
None known to me except removing the respective check from disklabel.
A workaround is to dump the label as displayed normally and then write
it, not using the disktab format.