On Thu, Oct 15, 2015 at 12:19 PM, Paolo Aglialoro <paol...@gmail.com> wrote:
> In order to minimise nand wear off, I would like to put on ramdisk (the
> machine would have 2GB ram, so I believe enough also for that, but I still
> can upgrade it to 4GB if needed) the parts of the file hierarchy with most
> intensive system write I/O, like, for instance, /tmp and I imagine some
> parts of /var.
>
> My questions are two:
> 1. What are the dirs I should take into account to go to ramdisk?
> 2. What is the correct filesystem type to put in fstab for all the entries
> of point 1. in order to store them in ramdisk?

I noticed that you have not said that you would like your other filesystems
to be read-only, only that you want the 'most intensive' writes to go to a
ramdisk.  In other words, you don't want your flash storage to be read-only,
you merely want it to be read-mostly.

I have done something similar myself and what I did was to make 2 mfs
filesystems: /tmp and /var/log.  here are my /etc/fstab entries:

  swap /tmp mfs rw,nodev,nosuid,-s=128M 0 0
  swap /var/log mfs rw,nodev,nosuid,-s=128M,-P=/mfs/log 0 0

Note that in my setup I have an /mfs/log partition.  This was originally the
/var/log partition from installation, which I renamed in /etc/fstab later
(after doing mkdir -p /mfs/log first).  This is a 'durable' copy of /var/log
meant to survive crashes, reboots or power failures.  The contents of
/var/log are periodically checkpointed to /mfs/log using rsync (installed
from packages), via a cron job:

  # checkpoint log files
  10 */4 * * * /usr/local/bin/rsync -aH --delete /var/log/ /mfs/log

Also, I added this line to /etc/rc.shutdown to handle reboots:

  /usr/local/bin/rsync -aH --delete /var/log/ /mfs/log

If /var/tmp isn't already a symbolic link to /tmp, do that as well to
redirect another commonly written directory to ramdisk.

You may also want to move cron log files from /var/cron to /var/log (or
/var/log/cron if you want them to be separated from other logs).  Doing so
involves modifying /etc/syslog.conf and /etc/newsyslog.conf.  If you do
this be prepared for warnings in the nightly security check emails due to the
cron log file not being found in its normal location.  Leaving an empty log
file in the original location is one workaround for this but I haven't tried
it.  A better workaround may be to modify the nightly check so that it looks
for the log file in its new location.

-ken

Reply via email to