Thumb Drive Organization

usb-flash-drive

A thumb drive is obviously a chunk of EEPROM, including a controller/microprocessor to store/retrieve the files stored on it. The operating system normally communicates with the thumb drive, and all thumb drives operate in all operating systems (I think). So there must be a protocol somewhere for how to address/command a thumbdrive over a USB port. I am interested in getting the data from a thumb drive that pertains to what memory blocks are actually occupied by a specific file. Does anybody out there know of a reference that describes thumb drive memory management and protocol?

I tried asking this on Stack Overflow and it was suggested I try here.

Best Answer

The way a USB Thumb Drive organizes data internally is transparent to a host.

Just like a hard drive, data is written and read using LBA (Logical Block Addressing):

http://wiki.osdev.org/LBA

When a host sends data to a LBA block on a Thumb Drive, the Thumb Drive is free to store that data in any way it likes, so long as the same data is returned when you read that block. You don't get to know how it stores the data on EEPROM (this can be very complex due to wear-levelling, error correction, and performance technologies being employed).

I am interested in getting the data from a thumb drive that pertains to what memory blocks are actually occupied by a specific file.

I suspect what you're actually looking for is information about what LBAs are in use by a particular file. That is a function of the file-system in use, and such information is obtained from the OS, not the USB device. That's because it's the OS that manages files and the mapping of file data to sectors and in turn the mapping of sectors to LBAs on the Thumb Drive.

This is excellent reading on the subject:

http://www.wd-3.com/archive/luserland.htm

Related Question