3

I want to understand the page size, sector size, block size (if applicable) of a usb flash drive. Is there a way for me to inspect those with Ubuntu?

mount /dev/sda1 /mnt
?
umount /dev/sda1

Edit

I'm interested in writing tests that might provide more coverage on the host side. I want to test writes of sizes smaller, equal to, and larger than the page size of the flash part and page size of the DRAM and/or eMMC of the host side.

How can I find the physical (not virtual) page size of the USB flash, my device's DRAM and my device's eMMC?

  • Are you sure it is /dev/sda ? – Basile Starynkevitch Jul 1 '15 at 19:36
  • Why do you ask? Why does it matter to you? Please edit your question to improve it and motivate it. – Basile Starynkevitch Jul 3 '15 at 4:49
  • IIUC, a DRAM has a line size, not a page size... – Basile Starynkevitch Jul 3 '15 at 5:30
1

I'm not sure it matters that much. You could fdisk -l /dev/sda ; However, usually /dev/sda is your hard or SSD disk, and the USB stick would be e.g. /dev/sdi (then run fdisk -l /dev/sdi). Do a dmesg just after plugging the stick to find out.

Be careful: very often /dev/sda is your system disk.

Once a file system is mounted from the USB key, you might run fsstat(1) if you have that (e.g. fsstat /dev/sdi1) and also df(1)

In practice, you very probably don't need, and won't be able to get reliably and faithfully, the page, sector, block sizes of an USB stick.

However, you'll better use not too small buffers when read(2)-ing or write(2)-ing them. I suggest using 32Kbytes or 64Kbytes buffer for USB key I/O operations. If you are going thru a filesystem most of the data is in fact in the page cache (and will probably be flushed at sync or umount time).

You probably cannot easily find the physical page size of your devices (in particular, because the hardware is probably not giving any way to query it). If that matters, dive into the complete technical specifications of your hardware (and I won't be surprised if you needed to sign an NDA to get them).

You might consider using commands to query the hardware: hwinfo, lsusb, etc... (but I believe they don't give what you want, because the hardware itself lacks such capabilities)

You could simply benchmark I/O operation with various buffer sizes (e.g. power of two from 512 bytes to 1Megabyte)

  • 2
    Note that you're describing how to get the block size of filesystems, and not the underlying hardware, although it is likely impossible to get the latter from the OS as it is opaque to it. I think you'd have to check the manufacturer's specs, if they publish them. – goldilocks Jul 1 '15 at 19:43
  • I believe that fdisk -l tells something about the hardware (and the partitions) since it does not work on file systems – Basile Starynkevitch Jul 1 '15 at 19:43
  • 2
    It says something, but it will just be "512 bytes logical size" which I am pretty sure is really a fiction used by the OS as a sort of placeholder. It's information that just does not apply to flash memory in the same way as it applies to spinning disks. Put another way, flash memory hardware does have a page and block size (referred to in the question), but they are abstracted away and they are neither meaningful to, nor determinable by, the OS. – goldilocks Jul 1 '15 at 19:49
  • ...Of course it's not clear the OP understands this...or whether it is really just about the block size of a filesystem... – goldilocks Jul 1 '15 at 19:51
  • 1
    Nope, absolutely don't understand that. I am trying to get at the page size of the underlying flash part. But I guess that's not possible. – tarabyte Jul 3 '15 at 4:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.