Way to find out SSD page size on Linux/Unix? What is “physical block” in fdisk output

ssd

Everywhere I read that internally SSDs are structured in 4K or larger "pages", which grouped in "blocks" of about 128-256 pages (1, 2). SSDs work with these pages and blocks, "they can only erase data at the block level" (thus the block of pages is called "[NAND] erase block"). And the 512B blocks for the partition are emulated (which is done for legacy reasons).

I'm trying to get educated on SSDs, since I have some weird lags/freezes during writes to my Sandisk U100 on Samsung 9 np900x3c laptop.
And one useful thing would be to correctly find out what pages/blocks my SSD has?

Is there a utility or /sys/... file on Linux to determine the SSD page size?

Or "the drive and Googling the part numbers on the NAND chips may be needed", as in the comment?

Googling my Sandisk SSD I cannot find a proper datasheet/spec.
But Sandisk and people do mention "4K random reads/writes".
Does it mean the disk has 4K pages?

Also, fdisk shows me sector size (both physical and logical) and I/O 512 byte:

Disk /dev/sda: 128.0 GB, 128035676160 bytes
255 heads, 63 sectors/track, 15566 cylinders, total 250069680 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x4b914713

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    50331647    25164800   83  Linux
/dev/sda2        50331648   239583231    94625792   83  Linux
/dev/sda4       239583232   250068991     5242880   82  Linux swap / Solaris

What is "physical" sector size here? It doesn't seem to be the parameter of the SSD drive itself, since everybody say SSD pages are 4K+. Is it the emulated parameter for the disk? And "logical" is the sector size for the partition?
Also, what is I/O size?

PS

This question is probably the same as this one for USB flash — the answer is missing the point there, man fsstat says fsstat displays the details associated with a file system and the question is about the disk itself. My post has more details, maybe it would attract better responses?

Best Answer

  • The physical block size reported by fdisk is the physical block size reported by the disk when asked. It seldom has any relationship with SSD pages or erase blocks.

  • 4 KiB reads/writes are a common measure of I/O performance, representing "small" I/O operations.

  • There is no standard way for a SSD to report its page size or erase block size. Few if any manufacturers report them in the datasheets. (Because they may change during the lifetime of a SKU, for example because of changing suppliers.) There is a whitepaper from Intel which suggests that 4 KiB alignment is enough.

  • For practical use just align all your data structures (partitions, payload of LUKS containers, LVM logical volumes) to 1 or 2 MiB boundaries. It's an SSD after all--it is designed to cope with usual filesystems, such as NTFS (which uses 4 KiB allocation units). If Windows considers that aligning partitions to 1 MiB is enough you can bet that any SSD manufacturer will make sure that their products work well with such a configuration.

  • Best leave about 5% to 10% of unallocated space outside any partitions. Having overprovisioned space is of great help to SSDs in maintaining their performance in time.

Related Question