# USB Flash drive mount error



## Day_JJ (Mar 22, 2012)

I am upgrading a FreeBSD server and have encountered a problem with mounting a USB flash drive. The system was on 6.3 and I upgraded to 9.0 using CVS repositories. The flash drive worked properly at all steps throughout the upgrade. However, after the OS upgrade was complete, I made a mistake and destroyed some of the server application. I set the upgraded drive aside, copied the source drive to a different spare, and repeated the upgrade process taking care to verify the functioning of the applications during the process.

When I finished the second time, everything worked properly except for mounting the flash drive.

This is the output from the first upgrade (3/11/2012) when the drive is inserted:

```
ugen4.2: <HP> at usbus4
umass0: <HP v165w, class 0/0, rev 2.00/32.76, addr 2> on usbus4
umass0:  SCSI over Bulk-Only; quirks = 0x0100
umass0:2:0:-1: Attached to scbus2
da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
da0: <hp v165w 3276> Removable Direct Access SCSI-4 device 
da0: 40.000MB/s transfers
da0: 30960MB (63406080 512 byte sectors: 255H 63S/T 3946C)
```
And *diskinfo* output:

```
da0
	512         	# sectorsize
	32463912960 	# mediasize in bytes (30G)
	63406080    	# mediasize in sectors
	0           	# stripesize
	0           	# stripeoffset
	3946        	# Cylinders according to firmware.
	255         	# Heads according to firmware.
	63          	# Sectors according to firmware.
	AA22064F00000035	# Disk ident.
```


This is the output from the second upgrade (3/18/2012) when the drive is inserted:

```
ugen4.2: <HP> at usbus4
umass0: <HP v165w, class 0/0, rev 2.00/32.76, addr 2> on usbus4
umass0:  SCSI over Bulk-Only; quirks = 0x0100
umass0:2:0:-1: Attached to scbus2
da0 at umass-sim0 bus 0 scbus2 target 0 lun 0
da0: <hp v165w 3276> Removable Direct Access SCSI-4 device 
da0: 40.000MB/s transfers
da0: 17454747090944MB (71776119061217281 512 byte sectors: 64H 32S/T 0C)
```
And *diskinfo* shows:

```
da0
	512         	# sectorsize
	-144115188075855360	# mediasize in bytes ()
	-281474976710655	# mediasize in sectors
	0           	# stripesize
	0           	# stripeoffset
	-137438953471	# Cylinders according to firmware.
	64          	# Heads according to firmware.
	32          	# Sectors according to firmware.
	AA22064F00000035	# Disk ident.
```

Since the size information is incorrect, the /dev/da0s1 device is not created and the drive cannot be mounted.

Does anyone else have a similar problem? Or a suggestion on how to fix this?

Thanks,


----------



## jb_fvwm2 (Mar 23, 2012)

Is /dev/da0 created? A few times I've found it mountable instead, unexpectedly.


----------



## Day_JJ (Mar 23, 2012)

Yes, /dev/da0 is created. But if I try to mount it, this is the result:

```
# mount -t msdosfs /dev/da0 /mnt/sd2
mount_msdosfs: /dev/da0: Input/output error
```

Incidentally, the failure only happens with a large flash drive. When I use a 4GB or 8GB drive the system does not have any problem.

BTW, can the disk geometry of a flash drive be specified in a manner similar to that of hard drives?


----------



## wblock@ (Mar 23, 2012)

Geometry is supposed to be reported by the device.  The freebsd-usb mailing list would be a good place to debug that.


----------



## Day_JJ (Mar 23, 2012)

Thanks wblock,


			
				wblock@ said:
			
		

> Geometry is supposed to be reported by the device.  The freebsd-usb mailing list would be a good place to debug that.



I know that the device should report the geometry. And it does for this flash drive on all of my systems except the one newly updated to 9.0. But it appears that something changed with the OS code that reads the firmware between the first time I ran cvsup on (about) the 9th and the second time I ran it about the 18th.

With some drives I have used in the past, I have specified the drive geometry using the fdisk Partition Editor. So, to clarify my question, is it safe to use the same process for a flash drive?


----------



## wblock@ (Mar 23, 2012)

fdisk(8) writes an MBR, but that's at a higher level and doesn't change what the device reports.  Or shouldn't, anyway, I don't know where diskinfo(8) is getting that information.


----------



## jb_fvwm2 (Mar 23, 2012)

sysutils/linuxfdisk  may give more information about the flash drive? Helped in one case here...


----------



## Day_JJ (Mar 23, 2012)

As suggested, I posted the problem to freebsd-usb. The response seems to mean I am still asking in the wrong place:


> This does not look like a USB problem. It is the SCSI/CAM layer which queries
> over SCSI USB how big the disk is
> <SNIP>
> So it looks like the mediasize was multiplied by 512 when it shouldn't.
> ...



Is there some other forum that is more appropriate for the question?


----------



## wblock@ (Mar 23, 2012)

freebsd-scsi, evidently.


----------



## Day_JJ (Mar 24, 2012)

Received the solution from Kaho Toshikazu.

Since the flash drive connected at 
	
	



```
ugen4.2: <HP> at usbus4
```
 the following fixes the problem:

```
# usbconfig -d 4.2 add_quirk UQ_MSC_NO_INQUIRY
# usbconfig -d 4.2 reset
```
Device /dev/da0s1 is then created and can be used normally.

Life is good!  THANKS


----------



## JoeSchmuck (Oct 17, 2012)

This posting was very valuable.  I hope a fix is coming so I don't have to type this every time.


----------

