This is an old revision of the document!
- SDcards in general wear out the fastest, then EMMC, then SSD
- There are industrial SDcards that last longer
- writing is what wears out cards.
- unpartitioned (unallocated) space improves wear-leveling since the sd/emmc/ssd controller sees the unallocated space as usable for wear leveling
Steps to create unpartitioned space to improve wear leveling on emmc
with emmc unmounted
sudo e2fsck -f /dev/mmcblk1p1 # check filesystem sudo resize2fs -M /dev/mmcblk1p1 # shrink filesystem to minimum size sudo fdisk /dev/mmcblk1 # shink partition sudo resize2fs /dev/mmcblk1p1 # Expand filesystem to fill the new (smaller) partition sudo partprobe /dev/mmcblk1 # refresh kernel partition table
inside fdisk
p – print table (to get start sector of p1) d – delete partition n – create new primary partition #1 Use same start sector Choose a smaller size that is slightly larger than the new filesystem w – write changes
Example
- Start sector was: 8192
- New end sector: something corresponding to ~5.2GB:
- 1 GiB = 1,073,741,824 bytes
- 5.2 × 1,073,741,824 = 5,583,457,484.8 bytes
- 5,583,457,485 / 512 ≈ 10,910,860 sectors
- end = 8192 + 10,910,860 - 1 = 10,919,051
Extend emmc by reducing logging
so that:
- temporary files created by programs go to RAM
- keeps logs/temp writes from wearing out eMMC
- mode=1777: world-writable sticky bit (normal for /tmp)
- limit size of files/logs
inside /etc/fstab
tmpfs /tmp tmpfs defaults,noatime,mode=1777,size=128M 0 0 tmpfs /var/tmp tmpfs defaults,noatime,mode=1777,size=64M 0 0 tmpfs /var/log tmpfs defaults,noatime,mode=0755,size=32M 0 0
Make journald log less aggressively
- you'll have no logs for boot failures
- inside
/etc/systemd/journald.conf
Storage=volatile RuntimeMaxUse=10M RuntimeKeepFree=2M SystemMaxUse=0 # ignored in volatile mode
lighten ext4 journaling
- in
/etc/fstab:/dev/mmcblk1p1 / ext4 noatime,data=writeback,barrier=1,commit=60 0 1noatime: don't update access time every time you read a filedata=writeback: lighter journaling (metadata-only)commit=60: group writes once per minute instead of 5 secondsbarrier=1: maintain safety- data=writeback + sudden power loss = some recently changed files may become garbage inside (but no FS corruption)