Subject: disklabel destroying MBR on NetBSD/i386 3.0
To: None <tech-userlevel@NetBSD.org>
From: Klaus Heinz <k.heinz.aug.sechs@kh-22.de>
List: tech-userlevel
Date: 08/14/2006 16:34:26
Hi,

I just observed the following with an empty disk on NetBSD/i386 3.0
(sources from around middle of July):

  # fdisk -u wd2  
  ...
    [ creating a primary, the extended and a logical partition ]
  ...


  # fdisk wd2
  Disk: /dev/rwd2d
  NetBSD disklabel disk geometry:
  cylinders: 484521, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
  total sectors: 488397168

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

  Partition table:
  0: Primary 'big' DOS, 16-bit FAT (> 32MB) (sysid 6)
      start 63, size 2088387 (1020 MB, Cyls 0-130)
  1: <UNUSED>
  2: <UNUSED>
  3: Ext. partition - LBA (sysid 15)
      start 2088450, size 486308718 (237455 MB, Cyls 130-30401/81/1)
  Extended partition table:
  E0: NetBSD (sysid 169)
      start 2088513, size 8385867 (4095 MB, Cyls 130-652)
  Bootselector disabled.



  # disklabel -e wd2
  ...
   [ doing nothing, but the label will be on disk now ]
  ...


  # disklabel -r wd2
  # /dev/rwd2d:
  type: ESDI
  disk: ST3250824A      
  label: fictitious
  flags:
  bytes/sector: 512
  sectors/track: 63
  tracks/cylinder: 255
  sectors/cylinder: 16065
  cylinders: 30401
  total sectors: 488397168
  rpm: 3600
  interleave: 1
  trackskew: 0
  cylinderskew: 0
  headswitch: 0           # microseconds
  track-to-track seek: 0  # microseconds
  drivedata: 0 

  7 partitions:
  #        size    offset     fstype [fsize bsize cpg/sgs]
   d: 488397168         0     unused      0     0        # (Cyl.     0 - 30401*)



  # disklabel -er wd2  
  ...
   [ doing nothing, but writing the temporary file in the editor ]
  ...
  NetBSD slice at 2088513, partition C at 0
  Write outside MBR partition? [n]: y



  # fdisk wd2
  ...
  Partition table:
  0: <UNUSED>
  1: <UNUSED>
  2: <UNUSED>
  3: <UNUSED>
  Bootselector disabled.

  # disklabel -r wd2
  ...
  7 partitions:
  #        size    offset     fstype [fsize bsize cpg/sgs]
   d: 488397168         0     unused      0     0        # (Cyl.    0 - 30401*)


After "disklabel -er" and the (unknown to me) question
"Write outside MBR partition?" the first block of the disk is destroyed
and the disklabel resides in the second disk block instead of the logical
NetBSD partition E0.

I assume this is not intended behaviour?

ciao
     Klaus