Table of Contents

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 # shrink partition
sudo resize2fs /dev/mmcblk1p1 # Expand filesystem to fill the new (smaller) partition

inside fdisk

execute the following commands:

p – print table (to get start sector of p1)
d – delete partition (I know this is scary but it will be OK)
n – create new primary partition #1
  - Use same start sector
  - Choose a smaller size that is slightly larger than the new filesystem
  - when asked "Partition #1 contains a ext4 signature. Do you want to remove the signature?" answer No
w – write changes
Example

Extend emmc by reducing logging

so that:

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

Storage=volatile
RuntimeMaxUse=10M
RuntimeKeepFree=2M
SystemMaxUse=0   # ignored in volatile mode

lighten ext4 journaling

not sure data=writeback especially is a good idea and will survive ungraceful powerdown ongoingly without then mounting as RO on reboot at some point due to corrupted system. I'm thinking though even though data corruption is more likely, it will not flag a disk corruption. Instead some file data may be lost.

enable Trim

sudo systemctl enable fstrim.timer # defaults to 1x/week
sudo systemctl start fstrim.timer

Zram

the below suggestions have not been tested

sudo apt update
sudo apt install zram-tools # or sudo apt install systemd-zram-generator
sudo nano /etc/systemd/zram-generator.conf

inside /etc/systemd/zram-generator.conf

# ===========================
# ZRAM configuration for BBB
# ===========================

[zram0]
# swap zram
type = swap
compression-algorithm = zstd
zram-size = 256M

[zram1]
# /var/log on zram
type = ext4
mount-point = /var/log
zram-size = 64M

[zram2]
# /tmp on zram (optional)
type = ext4
mount-point = /tmp
zram-size = 64M

then

sudo systemctl daemon-reload
sudo systemctl start /dev/zram0 # check if already started
sudo systemctl start /dev/zram1
sudo systemctl start /dev/zram2
# check
lsblk
zramctl
df -h
# disable journaling
tune2fs -O ^has_journal /dev/zram1 # do not do for zram0 Yes do for zram2
mkswap /dev/zram0

If using zram, remove the /tmp and /var/log lines in /etc/fstab or they will override zram mounts.