You will find some approaches to increase the life time of SD Cards used for the root file system of (Debian) GNU/Linux installations (like on most Raspberry Pi setups). The life time might be dramaticly increased by using a flash aware filesytem like NILFS or FSFS - but this is beyond of this article.
The default disk scheduler is cfq. It implements Completely Fair Queuing and is a non optimal choice for flash based block devices. The common choice is using the noop or deadline scheduler by adding the elevator parameter to the kernel command line (/boot/cmdline.txt):
Most embedded setups don’t care about files or directories access time property. The update can be completly disabled by the noatime and nodiratime mount options in /etc/fstab:
/dev/mmcblk0p1 /boot vfat defaults,noatime,nodiratime,fmask=0122 0 2 /dev/mmcblk0p2 / ext4 defaults,noatime,nodiratime 0 1
By default ntp saves some statistics periodicly to disk. This can be disable by dropping the statsdir statement in /etc/ntp.conf:
# Enable this if you want statistics to be logged. #statsdir /var/log/ntpstats/
Using rsyslog it is quite simple to forward syslog messages to a external host and prevent any log files to be written to the local disk. Just add those lines into /etc/rsyslog.d/local.conf:
$ModLoad immark # provides --MARK-- message capability $ActionQueueType LinkedList # use asynchronous processing $ActionQueueFileName logqueue # set file name, also enables disk mode $ActionResumeRetryCount -1 # infinite retries on insert failure $ActionQueueSaveOnShutdown on # save in-memory data if rsyslog shuts down *.* @@192.168.x.y # tcp syslog server & ~ # stop further processing of log ruleset
Due the queue filename rsyslog might write some data onto disk for caching purpose.
Tune the write caching of the linux kernel writing the following lines into /etc/sysctl.d/local.conf:
vm.dirty_background_ratio=20 vm.dirty_ratio=40 vm.dirty_writeback_centisecs=12000 vm.dirty_expire_centisecs=12000