# USB drive doesn't work



## eternal_noob (Feb 9, 2020)

Hi,

i've got an USB drive which i want to reformat. I just can't seem to get it working.

Plugging it in shows the following messages in /var/log/messages:

```
kernel: ugen7.2: <Silicon Motion,Inc. SM3259AA MEMORY BAR> at usbus7
kernel: umass0 on uhub0
kernel: umass0: <Silicon Motion,Inc. SM3259AA MEMORY BAR, class 0/0, rev 2.00/1.00, addr 2> on usbus7
kernel: umass0:  SCSI over Bulk-Only; quirks = 0x4000
kernel: umass0:8:0: Attached to scbus8
kernel: da0 at umass-sim0 bus 0 scbus8 target 0 lun 0
kernel: da0: <SMI USB MEMORY BAR 1000> Removable Direct Access SPC-3 SCSI device
kernel: da0: 40.000MB/s transfers
kernel: da0: Attempt to query device size failed: NOT READY, Medium not present
kernel: da0: quirks=0x2<NO_6_BYTE>
```

From this time on, i tried the following:

```
root@xxx:~ # dd if=/dev/zero of=/dev/da0 bs=2m count=1
dd: /dev/da0: Device not configured
1+0 records in
0+0 records out
0 bytes transferred in 0.002558 secs (0 bytes/sec)
```


```
root@xxx:~ # fdisk -i /dev/da0
fdisk: can't get disk parameters on /dev/da0
fdisk: cannot open disk /dev/da0: No such file or directory
```


```
root@xxx:~ # newfs_msdos /dev/da0
newfs_msdos: meta data exceeds file system size
```


```
root@xxx:~ # ls /dev/da0*
/dev/da0
```


```
root@xxx:~ # gpart show da0
gpart: No such geom: da0.
root@xxx:~ # gpart create -s gpt da0
gpart: provider: Operation not supported by device
```


```
root@xxx:~ # file -s /dev/da0
/dev/da0: ERROR: cannot read `/dev/da0' (Device not configured)
```

I am out of clues, got any advice?


----------



## George (Feb 9, 2020)

Weird.  Does your device show up in `camcontrol devlist`?
What version of FreeBSD are you running?

I think "gpart show" might not show devices, if you just wrote zeroes to them. Try `gpart list`, or `gpart status`.


----------



## ralphbsz (Feb 9, 2020)

freebsd_noob said:


> kernel: da0: Attempt to query device size failed: NOT READY, Medium not present


There you are. The USB device reports that it has no media in it. More accurately, the FreeBSD storage midlayer asked the USB device what its storage capacity is (on SCSI, that's done with the READ CAPACITY command, ATA=SATA uses a different command), and the device replied by saying that it is not ready to read the capacity, because the medium is not present.

If this is a device with removable media (CD or DVD player, or removable disk drive like the old Jaz drives), then please insert some readable or writable media. If this is not a removable device, then either the device is broken, or incompatible in a subtle fashion with the FreeBSD driver stack.

Once there is no media in the device, and operation on /dev/da0 will return errors, which different programs report in different ways. I think the error returned by low level code will be ENXIO or ENODEV, which are complex to understand and typically badly handled by callers.


----------



## eternal_noob (Feb 9, 2020)

Hi,

i am running FreeBSD 12.1-RELEASE-p2.

The device shows up in `camcontrol devlist`:

```
root@xxx:~ #  camcontrol devlist
# ... other devices ...
<SMI USB MEMORY BAR 1000>          at scbus8 target 0 lun 0 (da0,pass2)
```

but not in `gpart list` or `gpart status`.

Since there is no removable media (it's just a USB Pen Drive), i believe it's broken or not compatible with the FreeBSD driver stack.

Thank you both for your answers.


----------

