lwc:hardware:wear_leveling

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
lwc:hardware:wear_leveling [2025/11/13 18:58] John Harrisonlwc:hardware:wear_leveling [2025/11/14 10:58] (current) John Harrison
Line 9: Line 9:
 sudo e2fsck -f /dev/mmcblk1p1 # check filesystem sudo e2fsck -f /dev/mmcblk1p1 # check filesystem
 sudo resize2fs -M /dev/mmcblk1p1 # shrink filesystem to minimum size sudo resize2fs -M /dev/mmcblk1p1 # shrink filesystem to minimum size
-sudo fdisk /dev/mmcblk1 # shink partition+sudo fdisk /dev/mmcblk1 # shrink partition
 sudo resize2fs /dev/mmcblk1p1 # Expand filesystem to fill the new (smaller) partition sudo resize2fs /dev/mmcblk1p1 # Expand filesystem to fill the new (smaller) partition
-sudo partprobe /dev/mmcblk1 # refresh kernel partition table 
 </code> </code>
 === inside fdisk === === inside fdisk ===
 +execute the following commands:
 <code> <code>
 p – print table (to get start sector of p1) p – print table (to get start sector of p1)
-d – delete partition+d – delete partition (I know this is scary but it will be OK)
 n – create new primary partition #1 n – create new primary partition #1
-  Use same start sector +  Use same start sector 
-  Choose a smaller size that is slightly larger than the new filesystem+  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 w – write changes
 </code> </code>
Line 51: Line 52:
 </code> </code>
 === lighten ext4 journaling === === lighten ext4 journaling ===
-  * in ''/etc/fstab'': ''/dev/mmcblk1p1  /  ext4  noatime,data=writeback,barrier=1,commit=60  0  1''+//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.// 
 +  * in ''/etc/fstab'': ''/dev/mmcblk1p1  /  ext4  noatime,data=writeback,barrier=1,commit=60,errors=remount-ro   1''
     * ''noatime'': don't update access time every time you read a file     * ''noatime'': don't update access time every time you read a file
     * ''data=writeback'': lighter journaling (metadata-only)     * ''data=writeback'': lighter journaling (metadata-only)
Line 57: Line 59:
     * ''barrier=1'': maintain safety     * ''barrier=1'': maintain safety
     * data=writeback + sudden power loss = some recently changed files may become garbage inside (but no FS corruption)     * data=writeback + sudden power loss = some recently changed files may become garbage inside (but no FS corruption)
 +  * add/change the ''cmdline'' in ''uEnv.txt'' (otherwise ''data=writeback'' will cause kernel to remount partition as Read Only):
 +    * ''cmdline=coherent_pool=1M net.ifnames=0 lpj=1990656 rng_core.default_quality=100 root=/dev/mmcblk1p1 rw rootfstype=ext4 rootwait''
  
 === enable Trim === === enable Trim ===
- * When a file is deleted trim says to tell the OS to tell the flash controller that those blocks are no longer used. +  * When a file is deleted trim says to tell the OS to tell the flash controller that those blocks are no longer used. 
- * Unused blocks even in the file system can be used by the controller to help with wear leveling +  * Unused blocks even in the file system can be used by the controller to help with wear leveling 
- * Continuous trim is apparently a bad idea but for wear leveling a periodic trim of 1x/week is helpful"+  * Continuous trim is apparently a bad idea but for wear leveling a periodic trim of 1x/week is helpful
 <code> <code>
 sudo systemctl enable fstrim.timer # defaults to 1x/week sudo systemctl enable fstrim.timer # defaults to 1x/week
 sudo systemctl start fstrim.timer sudo systemctl start fstrim.timer
 +</code>
  
 ==== Zram ==== ==== Zram ====
- * Zram doesn't help wear leveling directly but helps to maximize RAM availability so it can be helpful if that's an issue:+  *Zram doesn't help wear leveling directly but helps to maximize RAM availability so it can be helpful if that's an issue: 
 +//the below suggestions have not been tested//
 <code> <code>
 sudo apt update sudo apt update
  • lwc/hardware/wear_leveling.1763081910.txt.gz
  • Last modified: 2025/11/13 18:58
  • by John Harrison