I have switched from using a hard drive for my soekris 4801 to a 512MB CF card. This has changed the system quite a bit. It makes it quieter, slower, and more likely to get worn out with a lot of write activity.
This didn't require any real technical marvel, but it is motivation to reduce the amount of write activity. My soekris performs the following major functions:
First I wanted to reduce the writes to /, so I used the following options in my fstab:
#/etc/fstab /dev/wd0a / ffs rw,noatime,nodevmtime 1 1These options, obviously, reduce the amount of write operations done on / when files and devices are accessed.
Disable mtree checking in /etc/security.conf
Now remove mail delivery from weekly, daily, and monthly stuff:
# crontab -e #Remove tee with sendmail to simple redirect 15 3 * * * /bin/sh /etc/daily 2>&1 > /var/log/daily.out 30 4 * * 6 /bin/sh /etc/weekly 2>&1 > /var/log/weekly.out #30 5 1 * * /bin/sh /etc/monthly 2>&1 > /var/log/monthly.out
The next step is to take make /var, which is the most write-heavy directory structure, and make it less of a pain. To do this I mount of the most written subdirectories as mfs (memory file system).
#/etc/fstab /dev/wd0b /var/run_mfs mfs rw,hidden,-s1M 0 0 /dev/wd0b /var/log_mfs mfs rw,hidden,-s10M 0 0 /var/run_mfs /var/run union rw - - /var/log_mfs /var/log union rw - -To explain these- '/dev/wd0b' is my swap partition, '/var/run_mfs' & '/var/log_mfs' are the mount targets, 'mfs' is the type, 'rw' is the read-write option, '-s1m' & '-s10m' are the size of the mounts (1MB and 10MB respectively), and '0 0' is fsck stuff. The union mounts seed all of the files into the mfs. Now to make this work, I need to have them mounted before the daemons start. NetBSD's awesome rc system has something for this:
#/etc/rc.conf critical_filesystems_local="/var/run /var/log"Now my filesystems will mount over the on-disk versions before any other daemons are started.
dhclient normally writes leases in /var/db, to change that I use:
#/etc/rc.conf dhclient=YES dhclient_flags="-nw -lf /var/run/dhclient.leases sip0"
dhcpd, similarly needs options, but it won't startup if the leases file does not exist at all. This would normally mean that dhcpd.leases would get written to disk, but there is an easy workaround!
#/etc/syslog.conf #use syslog to create a dhcpd.leases file, but don't write anything to it. notarealdeamon.info /var/run/dhcpd.leasesNow syslog will touch our file for us and we can put our options in:
#/etc/rc.conf dhcpd=YES dhcpd_flags="-lf /var/run/dhcpd.leases sip1"
#/usr/pkg/etc/httpd/httpd.conf ErrorLog syslog CustomLog "|/usr/bin/logger -i -t httpd" combinedBecause you're using syslog to log everything to a small memory partition, you may want to adjust /etc/newsyslog.conf to be more aggressive in rotation size, but I didn't need to do this.
#/etc/fstab /dev/sd0a /usr/local/htdocs ffs rw 1 1