Subject: kern/23257: BUFFALO ClipDrive USB flash drive cannot read sector 0
To: None <gnats-bugs@gnats.netbsd.org>
From: None <cjs@cynic.net>
List: netbsd-bugs
Date: 10/24/2003 15:23:47
>Number:         23257
>Category:       kern
>Synopsis:       BUFFALO ClipDrive USB flash drive cannot read sector 0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Oct 24 06:24:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Curt Sampson
>Release:        NetBSD 1.6ZD 2003-10-20 (everything from 1.6K onwards, in fact)
>Organization:
>Environment:
Architecture: i386
Machine: i386
>Description:
    I have a 256 MB flash drive called a Buffalo (or MELCO) ClipDrive.
    I can fdisk it, disklabel it, newfs a partition, and use that for data
    storage, but I seem unable to read the first sector, and sometimes others,
    at least under certain circumstances.
>How-To-Repeat:
    Insert it and try to do various operations:

    $ dd if=/dev/rsd1d of=/dev/null
    0+0 records in
    0+0 records out
    0 bytes transferred in 0.007 secs (0 bytes/sec)

    $ dd if=/dev/rsd1d of=/dev/null skip=128
    0+0 records in
    0+0 records out
    0 bytes transferred in 0.007 secs (0 bytes/sec)

    # dd if=/dev/zero of=/dev/sd1d count=128
    128+0 records in
    128+0 records out
    65536 bytes transferred in 1.059 secs (61884 bytes/sec)

    # dd if=/dev/rsd1d of=/dev/null         
    0+0 records in
    0+0 records out
    0 bytes transferred in 0.006 secs (0 bytes/sec)

    # fdisk -i sd1
    [seems to work ok]
    # fdisk -u sd1
    [set up partition 3 as ID 169; seems to work ok]
    # ./fdisk sd1
    Disk: /dev/rsd1d
    NetBSD disklabel disk geometry:
    cylinders: 250, heads: 64, sectors/track: 32 (2048 sectors/cylinder)
    total sectors: 512000

    BIOS disk geometry:
    cylinders: 250, heads: 64, sectors/track: 32 (2048 sectors/cylinder)
    total sectors: 512000

    Partition table:
    0: NetBSD (sysid 169)
	start 32, size 511968 (250 MB, Cyls 0-250), Active
    1: <UNUSED>
    2: <UNUSED>
    3: <UNUSED>
    Bootselector disabled.

    # disklabel -i -e sd1
    disklabel: Can't read master boot record 0: No such file or directory
    [set a a label, things seem ok, except for above error message]
    ironic # disklabel -r sd1
    disklabel: can't read master boot record: No such file or directory
    # /dev/rsd1d:
    type: SCSI
    disk: ClipDrive
    label: cjs
    flags: removable
    bytes/sector: 512
    sectors/track: 32
    tracks/cylinder: 64
    sectors/cylinder: 2048
    cylinders: 250
    total sectors: 512000
    rpm: 3600
    interleave: 1
    trackskew: 0
    cylinderskew: 0
    headswitch: 0           # microseconds
    track-to-track seek: 0  # microseconds
    drivedata: 0 

    5 partitions:
    #        size    offset     fstype  [fsize bsize cpg/sgs]
     a:    511968        32     4.2BSD      0     0     0   # (Cyl.    0*- 249)
     c:    511968        32     unused      0     0         # (Cyl.    0*- 249)
     d:    512000         0     unused      0     0         # (Cyl.    0 - 249)

    [newfs /dev/rsd1a, put /boot on it; all seems ok]

    ironic # ../sbin/installboot -v /dev/rsd1a bootxx_ffsv1
    File system:         /dev/rsd1a
    File system type:    ffs (blocksize 8192, needswap 0)
    Primary bootstrap:   bootxx_ffsv1
    installboot: Reading `/dev/rsd1a': short read
    installboot: Set bootstrap operation failed

I have another 128 MB USB flash drive ("Genuine") which works fine with the
same operations above.

>Fix:
    FreeBSD claims to support this in current, but I've not tested it.
    Maybe there's some clues there.
>Release-Note:
>Audit-Trail:
>Unformatted: