Subject: bin/34807: fdisk displays sector wrongly
To: None <gnats-admin@netbsd.org, netbsd-bugs@netbsd.org>
From: None <jam@pobox.com>
List: netbsd-bugs
Date: 10/13/2006 13:30:01
>Number:         34807
>Category:       bin
>Synopsis:       fdisk displays sector number wrongly
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 13 13:30:01 +0000 2006
>Originator:     Kazushi (Jam) Marukawa
>Release:        NetBSD 4.99.3
>Organization:
none
>Environment:
System: NetBSD fs 4.99.3 NetBSD 4.99.3 (XEN3_DOM0) #1: Sat Sep 30 20:35:41 JST 2006 jam@fs:/var/obj/mnt/raid/netbsd/current/src/sys/arch/i386/compile/XEN3_DOM0 i386
Architecture: i386
Machine: i386
>Description:
	I connected a 1.8G RAID5 disk (hard-ware RAID) to NetBSD.  Then,
	ran fdisk -u.  fdisk says following:

	    # fdisk ld0
	    fdisk: primary partition table invalid, no magic in sector 0
	    fdisk: Cannot determine the number of heads
	    Disk: /dev/rld0d
	    NetBSD disklabel disk geometry:
	    cylinders: 233418, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
	    total sectors: 3749867520

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

	    Partition table:
	    0: <UNUSED>
	    1: <UNUSED>
	    2: <UNUSED>
	    3: <UNUSED>
	    Bootselector disabled.
	    root@fs(p2)# fdisk -u ld0
	    fdisk: primary partition table invalid, no magic in sector 0
	    fdisk: Cannot determine the number of heads
	    Disk: /dev/rld0d
	    NetBSD disklabel disk geometry:
	    cylinders: 233418, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
	    total sectors: 3749867520

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

	    Do you want to change our idea of what BIOS thinks? [n]

	    Partition table:
	    0: <UNUSED>
	    1: <UNUSED>
	    2: <UNUSED>
	    3: <UNUSED>
	    Bootselector disabled.
	    Which partition do you want to change?: [none] 0
	    The data for partition 0 is:
	    <UNUSED>
	    sysid: [0..255 default: 169]
	    start: [0..233418cyl default: 63, 0cyl, 0MB]
	    size: [0..233418cyl default: -545099839, 233418cyl, 4294701135MB]
	    bootmenu: []

	    Partition table:
	    0: NetBSD (sysid 169)
		start 63, size 3749867457 (1830990 MB, Cyls 0-233418/116/43)
	    1: <UNUSED>
	    2: <UNUSED>
	    3: <UNUSED>
	    Bootselector disabled.
	    Which partition do you want to change?: [none]

	    We haven't written the MBR back to disk yet.  This is your last chance.
	    Partition table:
	    0: NetBSD (sysid 169)
		start 63, size 3749867457 (1830990 MB, Cyls 0-233418/116/43)
	    1: <UNUSED>
	    2: <UNUSED>
	    3: <UNUSED>
	    Bootselector disabled.
	    Should we write new partition table? [n] y

	fdisk said "default: -545099839, 233418cyl, 4294701135MB".
	-545099839 sectors, 233418 cylinders, 4,294TB.  I wish if
	I had such big drives.  ;-)

	Nevermind.  Anyway, a part of fdisk output was wrong.
>How-To-Repeat:
	Connect 1.8TB disk and initialize it by fdisk?
>Fix:
	fdisk source code has too many "int" although it should be
	"unsigned int" or "daddr_t".  I'm not sure how to fix all.