[sf-lug] Trying to determine the actual size of a USB drive

Rick Moen rick at linuxmafia.com
Mon Aug 29 20:13:32 PDT 2011


Quoting John Magolske (b79net at gmail.com):

> I'd like to determine with certainty whether this is an 8GB or 16GB
> drive. Someone suggested copying a file larger than 8GB to the drive
> and comparing the copied file to the original...maybe with CMP(1) or
> using checksums. I'm wondering if there might be another way, as I'd
> rather not erase everything currently on the drive. I'd also like to
> avoid adding more write cycles to its flash storage chip.

Well... the only really logically conclusive way to determine the
capacity of a mass-storage device is indeed to store data there, and see
how much it holds.  Short of that:  'dmesg | less' should show you quite
a bit of what the kernel is probing about that USB device after the USB
layer notices its attachment.  Like this:

[1805079.078028] usb 1-7: new high speed USB device using ehci_hcd and address 19
[1805079.192955] usb 1-7: New USB device found, idVendor=0781, idProduct=5151
[1805079.192961] usb 1-7: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[1805079.192965] usb 1-7: Product: Cruzer Micro
[1805079.192968] usb 1-7: Manufacturer: SanDisk Corporation
[1805079.192971] usb 1-7: SerialNumber: 200411013209D0E19389
[1805079.193646] usb 1-7: selecting invalid altsetting 1
[1805079.194292] scsi10 : usb-storage 1-7:1.0
[1805080.194713] scsi 10:0:0:0: Direct-Access     SanDisk  Cruzer Micro     0.1  PQ: 0 ANSI: 2
[1805080.195735] sd 10:0:0:0: Attached scsi generic sg2 type 0
[1805080.197322] sd 10:0:0:0: [sdb] 2001888 512-byte logical blocks: (1.02 GB/977 MiB)
[1805080.197815] sd 10:0:0:0: [sdb] Write Protect is off
[1805080.197822] sd 10:0:0:0: [sdb] Mode Sense: 03 00 00 00
[1805080.197826] sd 10:0:0:0: [sdb] Assuming drive cache: write through
[1805080.201193] sd 10:0:0:0: [sdb] Assuming drive cache: write through
[1805080.202207]  sdb: sdb1
[1805080.203445] sd 10:0:0:0: [sdb] Assuming drive cache: write through
[1805080.203453] sd 10:0:0:0: [sdb] Attached SCSI removable disk
[1805111.496701] FAT: utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!
[1805111.497314] FAT: invalid media value (0x01)
[1805111.497320] VFS: Can't find a valid FAT filesystem on dev sdb.
[1805114.296751] FAT: utf8 is not a recommended IO charset for FAT filesystems, filesystem will be case sensitive!
[1805455.531751] usb 1-7: USB disconnect, address 19



See that?  Kernel believes this to be a 1 GB flash drive (and it's correct).





More information about the sf-lug mailing list