Subject: Re: writing a disklabel
To: Eric W. Bates <ericx@vineyard.net>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: port-sparc
Date: 11/28/1997 07:35:47
> I have a Quantum Fireball_TM2110S (2.1 Gb).

(Probably closer to 2G; disk manufacturers routinely lie about their
disks' sizes - see below.)

> I do not believe there is a description of this device in the
> disktab.

> Has anyone written one?  Or point me towards more info to read about
> how to write one?

> So far I have: [...]

During boot, the kernel prints lines describing the device, stuff like

sd0 at scsibus0 targ 0 lun 0: <IBM, WDS-L160, S510> SCSI1 0/direct fixed
sd0: 163MB, 1923 cyl, 4 head, 43 sec, 512 bytes/sec x 334601 sectors

The only number I pay any attention to here is the "sectors" count
(though the size in MB is printed, and you will likely find your
"2.1GB" disk is actually more like 2G, if that - I have a Seagate
ST12400N that was sold as 2.1G, but it's actually 4194685 sectors,
which is only marginally more than 2G (2.00018+, actually); NetBSD
prints "2048MB" for it).

The rest of the disklabel I fill in with numbers like these:

sunlabel> L
ascii: Fujitsu M2266S-512, 1658cx15hx84s, 2107704x512
rpm: 3600       pcyl: 1032      apc: 0          obs1: 0
obs2: 0         intrlv: 1       ncyl: 1030      acyl: 0
nhead: 32       nsect: 64       obs3: 0         obs4: 0
sunlabel> 

(where the ascii label string contains manufacturer, model, the numbers
reported by the kernel at boot time, and the actual size).  That is, I
completely ignore the sect/track and tracks/cyl values, using 64 and 32
for those (thus using "cylinders" of 1MB).  I then set the cylinders
value to the size of the disk in megabytes, rounded up.

I do this because almost all disks these days - especially even vaguely
modern disks - are ZBR disks, on which the number of sectors per track
varies depending on the cylinder number.  It thus is simply not
possible to "tell the truth" in the disk label.  Since disks also tend
to have large caches and other factors which wreck the neat model FFS's
knowledge of disk geometry was built around, I don't bother even
trying, and instead go for the convenience of having 1MB "cylinders" on
all my disks.

In terms of disklabel, this becomes something like

> #/dev/rsd4c
> type: SCSI
> disk: SCSI disk
> label: Quantum TM2110S
> flags:
> bytes/sector: 512
sectors/track: 64
tracks/cylinder: 32
sectors/cylinder: 2048
cylinders: (total sectors, divided by 2048, rounded up)
total sectors: (per the boot-time message)
> rpm: 4500
> interleave: 1
> trackskew: 0
> cylinderskew: 0
> headswitch: 0		# milliseconds
> track-to-track seek: 0	# milliseconds
> drivedata: 0

					der Mouse

			       mouse@rodents.montreal.qc.ca
		     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B