meta data for this page
Reduce SD Card wearing
Check who is writing
Start logging disc access and kernel log:
sysctl vm.block_dump=1 dmesg -e -T -w
Stop logging:
sysctl vm.block_dump=0
Set noop elevator
- /etc/rc.local
... echo noop > /sys/block/mmcblk0/queue/scheduler exit 0
Use tmpfs
- /etc/fstab
tmpfs /tmp tmpfs defaults,nosuid,nodev,mode=1777,size=10% 0 0 tmpfs /var/tmp tmpfs defaults,nosuid,nodev,mode=1777,size=10% 0 0 tmpfs /var/cache/apt/archives tmpfs defaults,nosuid,nodev,mode=1777,size=80% 0 0
Move some volatile dirs to tmp folder:
rm -rf /var/run /var/lock ln -s /run /var/run ln -s /run/lock /var/lock
rm -rf /var/lib/dhcp/ /var/spool ln -s /tmp /var/lib/dhcp ln -s /tmp /var/spool;
Disable logging to disc
systemctl stop mosquitto systemctl disable mosquitto
apt-get remove anacron
Remove syslog
dpkg --purge rsyslog
Use syslog from busybox package with circular log buffer in RAM:
apt-get install busybox-syslogd
SYSLOG_OPTS="-C256 -L -R remote.host.org" KLOG_OPTS=""
Use journald and configure it to use RAM:
- /etc/systemd/journald.conf
Storage=volatile Compress=yes
Run fstrim weekly
Check TRIM support
sudo hdparm -I /dev/sda | grep "TRIM supported"
- /etc/systemd/system/fstrim.service
[Unit] Description=Discard unused blocks [Service] Type=oneshot ExecStart=/sbin/fstrim -av
- /etc/systemd/system/fstrim.timer
[Unit] Description=Discard unused blocks once a week Documentation=man:fstrim [Timer] OnCalendar=weekly AccuracySec=1h Persistent=true [Install] WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable fstrim.timer
Broken SD Card
Bad magic number in super-block
[ 7000.203888] F2FS-fs (sda2): Magic Mismatch, valid(0xf2f52010) - read(0x0) [ 7000.203926] F2FS-fs (sda2): Can't find valid F2FS filesystem in 1th superblock
e2fsck /dev/sda2 e2fsck 1.42.12 (29-Aug-2014) ext2fs_open2: Bad magic number in super-block e2fsck: Superblock invalid, trying backup blocks... /dev/sda2: recovering journal e2fsck: unable to set superblock flags on /dev/sda2 /dev/sda2: ***** FILE SYSTEM WAS MODIFIED ***** /dev/sda2: ********** WARNING: Filesystem still has errors **********
To get superblock backups, simulate fs creation
sudo mke2fs -n /dev/xxx
Then run fsck with superblock backup
sudo e2fsck -b block_number /dev/xxx