Date added: June 26, 2018
Affected Products: EDM1-CF-IMX6 , EDM1-CF-IMX6SX , EDM1-FAIRY , EDM1-GNOME , EDM1-GOBLIN , EDM1-IMX6PLUS , EDM1-IMX7D , EDM2-ELF , EDM2-GREMLIN , EDM2-IMX6PLUS , PICO-DWARF , PICO-HOBBIT , PICO-IMX6 , PICO-IMX6UL-EMMC , PICO-IMX7 , PICO-IMX8M , PICO-NYMPH , TAM-3517 , TAO-3530 , TC-0700 , TC-0710 , TC-1010 , TDM-3730 , TEK3-IMX6 , TEK3-IMX6UL , TEP-0500-IMX6UL , TEP-0500-IMX7 , TEP-0700-IMX6UL , TEP-0700-IMX7 , TEP-1010-IMX6 , TEP-1560-IMX6 , THB-3517 , TWP-1010-IMX6 , TWP-1560-IMX6
This mini article shows how to format an ext4 partition on an eMMC storage or SD card in a way that can improve the perormance and reduce the wear on the device.
Physically SD cards or eMMC storage devices store its content in something called erase blocks.
One erase block is (roughly) the smallest unit that can be accessed by one read, write or erase operation. The size of an erase block varies between devices, but are typically around 256kB or 512kB. Every time a smaller amount of data is to be read or written the whole erase block is read, modified in memory, and then written again. Potentially causing many unneccesary reads and writes.
While this sounds quite bad, modern linux kernels (and eMMC firmwares) are getting better at keeping content cached and not updating the physical storage as often. But especially older kernels and older eMMC chips this could impact performance and wear quite badly.
There is no 100% cure. One thing that can be done is to format the filesystem in a way that aligns its internal data blocks better with the physical characteristics of modern eMMC / SD storage. The default settings are still optimized for rotating mechanical hard drives, which are very different from modern flash-based storage.
TechNexion engineers use the following commands to format linux ext4 partitions:
# mkfs.ext4 -E stripe-width=64,stride=64 -O sparse_super -m0 -J size=4 /dev/sddX
# tune2fs -O ^huge_file /dev/sddX
# tune2fs -c -1 /dev/sddX
sddX is the partition to format.
By mount the filesystem with the
noatime option can reduce wear and increase speed since the filesystem is not updating every file access time. (Even if updating a timestamp is not much data, due to the nature of erase blocks even small updates can cause largish writes).