Subject: disk geometry issue ?
To: None <port-i386@NetBSD.org>
From: Samuel Lacas <samuel.lacas@trusted-logic.fr>
List: port-i386
Date: 07/13/2005 09:38:00
Hello,

This is a riddle I submit to you guys, because no
one was able to solve it around me. This message
is rather long, but I wish it to contain
everything that I know on the subject.

Several
monthes ago, I reported strange disk/filesystem
corruptions on my computer, which were partially
solved, at least, that's what I believed.

After a crash caused by a brutal power loss, I was
forced to re-install everything on my HD. Briefly,
I intend to have a dual-boot system, NT and
NetBSD, possibly sharing a third DOS/FAT partition.
So far, I was not able to get a working system, as
running one randomly corrupts the other, I mean,
for instance:

   -installing NetBSD corrupts the NT filesystem,
   and reciprocally, randomly (some install did,
   other did not, depending on the partitions).
   -writing NT or DOS filesystem corrupts NetBSD's
    one
   -mounting/writing files on the DOS FS from
    NetBSD is OK, but the FS seems corrupted if
    read from NT.

Other facts:

  - I've made extensive memory tests; my RAM is
    fine, at least according to them.
  - Maxtor tools say the disk is OK (no bad sector,
    etc.)
  - Using only one system for a long time raise no
    issue.
  - As far as I understand what is written in the
    MBR, the partitions do not overlap.

All this makes me think that I have a disk
geometry issue (this was a hint from a fellow list
member, some monthes ago), but I really don't know
how to solve it.

Here is the crunchy, gory stuff:

My disk is a Maxtor 6Y160P0 (160GB).

The Maxtor tool says that the physical geometry
is 317 632 cylinders, 16 heads and 63 sectors.
Total number of sectors is 320 173 056.

The BIOS sees 163 Gb, divided in

    16 643 Cyls    |
    255    Heads   |  LBA mode
    63     Sectors |

    65 535 Cyls    |
    16     Heads   |  CHS mode
    255    Sectors |

I tried both the CHS and the LBA mode, to no
avail. Currently, I use the LBA mode.

NetBSD boot messages report 152 Gb
and the physical geometry (as given by the Maxtor
tool).

Partition Magic tells me that the physical
geometry is 19929 Cyls, 255 Heads, 63 sectors.
(in CHS, it says 21175/240/63).

PFDISK (FreeBSD DOS tool) says 1024/255/63 and
reports the following partition table:

# ID   1st cyl  Last cyl  Sectors (1st, last)

1 12    1023     9730     122881185,33447330
       (1023,0,1) (1023,254,63) physical
       (7649,0,1) (9730,254,63) logical

2 169   1023     19929    156328515, 163844541
       (1023,0,1) (1023,216,63) physical
                  (1023,216,63) should be (1024,254,63)
       (9731,0,1) (19929,216,63) logical

3 7     0        7648      63, 122881122
                  (1023,254,63) physical
                  (7648,254,63) logical

Both DOS tool seems to agree on the
19929/255/63 physical geometry (?).
This geometry is rejected by the NetBSD installer.

The NT installer tells me about a 130Gb disk, but
I have no other information.

Here are the outputs of fdisk and disklabel:

--------------------------------------------------
 > Disk: /dev/rwd0d
 > NetBSD disklabel disk geometry:
 > cylinders: 317632, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
 > total sectors: 320173056
 >
 > BIOS disk geometry:
 > cylinders: 1024, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
 > total sectors: 320173056
 >
 > Partition table:
 > 0: Primary DOS with 32 bit FAT - LBA (sysid 12)
 >     start 122881185, size 33447330 (16332 MB, Cyls 7649-9731)
 > 1: NetBSD (sysid 169)
 >     bootmenu: bsd
 >     start 156328515, size 163844541 (80002 MB, Cyls 9731-19929/217/1)
 > 2: OS/2 HPFS or NTFS or QNX2 or Advanced UNIX (sysid 7)
 >     bootmenu: winNT
 >     start 63, size 122881122 (60001 MB, Cyls 0-7649), Active
 > 3: <UNUSED>
 > Bootselector disabled.
--------------------------------------------------

Yes, there are two control chars on partition#1's
bootmenu label. I always get them, on either one
of the labels. That is, on every bootloader
installation, either the NT or the BSD label is
suffixed with control chars. The bootselector
works fine, however. End of parenthesis.

--------------------------------------------------
# /dev/rwd0d:
type: unknown
disk: Maxtor 6Y160P0
label:
flags:
bytes/sector: 512
sectors/track: 63
tracks/cylinder: 16
sectors/cylinder: 1008
cylinders: 317632
total sectors: 320173056
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0		# microseconds
track-to-track seek: 0	# microseconds
drivedata: 0

16 partitions:
#        size    offset     fstype [fsize bsize cpg/sgs]
  a:  73681776 156328515     4.2BSD   1024  8192 46640  # (Cyl. 155087*- 
228184*)
  b:   2097648 230010291       swap                     # (Cyl. 228184*- 
230265*)
  c: 163844541 156328515     unused      0     0        # (Cyl. 155087*- 
317631)
  d: 320173056         0     unused      0     0        # (Cyl.      0 - 
317631)
  e:  33447330 122881185      MSDOS                     # (Cyl. 121905*- 
155087*)
  f:  51200352 232107939     4.2BSD   1024  8192 46632  # (Cyl. 230265*- 
281059*)
  g: 122881122        63       NTFS                     # (Cyl.      0*- 
121905*)
  h:  16384032 283308291     4.2BSD   1024  8192 46552  # (Cyl. 281059*- 
297313*)
  i:  20480733 299692323     4.2BSD   1024  8192 46552  # (Cyl. 297313*- 
317631)
--------------------------------------------------

Currently, the system is unusuable: extensive
writing on NetBSD FS corrupts the NT partition.
If someone may help, I would be very glad.

Sincerely yours,

sL

PS: I won't be able to read my mail from Tuesday, 14th July
to Sunday, 17th July. I hope to hear from you on Monday :)