Please note, ryecoaaron made a plugin to automate this procedure, see this post for details [Tutorial][Experimental]Reducing OMV's disk writes, also to install it on USB flash
----------------------back to original first post--------------------
I'm a bit puzzled that it's none's priority to tame a bit OMV to allow the use of USB flash drives for OS drive like they do for FreeNas. Or even to let hard drives rest a bit.
Shedding some light on the matter myself then.
WARNING: This system is experimental, that is, it has not been throughly tested on multiple stations to ensure everything works fine in all situations.
I CANNOT GUARANTEE DATA SAFETY. DO BACKUPS OR DO NOT TRY IT.
Volunteers that test this system are welcome.
Let's track down what files got written often, with a script I took from here http://info4admins.com/tips-to…disk-in-debian-or-ubuntu/
#!/bin/sh
echo Search whole filesystem for changed files in the last $1 minutes
find /bin /dev /etc /home /lib /media /mnt /opt /root /sbin /srv /tmp /usr /var -cmin -$1
Place this in a /bin folder you create in your /home folder, then chmod a+x the script to make it executable.
Then you can call it by writing its name and the number of minutes you want.
ScriptName 5 will give you an output listing files written in the last 5 minutes
this is a real-life example:
Search whole filesystem for changed files in the last 5 minutes
/dev/xconsole
/etc/samba
/etc/samba/dhcp.conf
/tmp
/var/spool/postfix/maildrop
/var/spool/postfix/maildrop/8C728FC9A
/var/lib/monit/state
/var/lib/openmediavault/rrd
/var/lib/openmediavault/rrd/cpu-0-week.png
/var/lib/openmediavault/rrd/df-root-week.png
/var/lib/openmediavault/rrd/interface-eth0-hour.png
/var/lib/openmediavault/rrd/cpu-0-day.png
/var/lib/openmediavault/rrd/cpu-0-hour.png
/var/lib/openmediavault/rrd/df-media-a4db3b26-75a4-4677-b32e-0abbe0e9c62c-day.png
/var/lib/openmediavault/rrd/df-media-a4db3b26-75a4-4677-b32e-0abbe0e9c62c-month.png
/var/lib/openmediavault/rrd/cpu-0-year.png
/var/lib/openmediavault/rrd/interface-eth0-week.png
/var/lib/openmediavault/rrd/df-media-a4db3b26-75a4-4677-b32e-0abbe0e9c62c-week.png
/var/lib/openmediavault/rrd/load-day.png
/var/lib/openmediavault/rrd/df-root-month.png
/var/lib/openmediavault/rrd/df-media-a4db3b26-75a4-4677-b32e-0abbe0e9c62c-year.png
/var/lib/openmediavault/rrd/interface-eth0-year.png
/var/lib/openmediavault/rrd/load-hour.png
/var/lib/openmediavault/rrd/df-root-year.png
/var/lib/openmediavault/rrd/cpu-0-month.png
/var/lib/openmediavault/rrd/df-media-a4db3b26-75a4-4677-b32e-0abbe0e9c62c-hour.png
/var/lib/openmediavault/rrd/interface-eth0-month.png
/var/lib/openmediavault/rrd/interface-eth0-day.png
/var/lib/openmediavault/rrd/df-root-hour.png
/var/lib/openmediavault/rrd/df-root-day.png
/var/lib/rrdcached/db/localhost/interface-eth0/if_octets.rrd
/var/lib/rrdcached/db/localhost/interface-eth0/if_packets.rrd
------------a bunch of entries removed for space reasons----------
/var/lib/rrdcached/db/localhost/cpu-0/cpu-softirq.rrd
/var/lib/rrdcached/db/localhost/cpu-0/cpu-idle.rrd
/var/lib/rrdcached/db/localhost/cpu-0/cpu-steal.rrd
/var/lib/rrdcached/db/localhost/cpu-0/cpu-user.rrd
/var/lib/rrdcached/db/localhost/cpu-0/cpu-nice.rrd
/var/lib/rrdcached/db/localhost/cpu-0/cpu-system.rrd
/var/lib/rrdcached/db/localhost/cpu-0/cpu-interrupt.rrd
/var/lib/rrdcached/db/localhost/cpu-0/cpu-wait.rrd
/var/lib/rrdcached/journal/rrd.journal.1415583612.312057
/var/log/debug
/var/log/auth.log
/var/log/daemon.log
/var/log/syslog
Display More
The bulk of that output you see is mostly performance logging to allow OMV to make pretty graphs, and pre-made images of graphs for a page in the webGUI. And it is done pretty often, waay too often.
So, now we have a general idea of what is going on in the disk and we can start our countermeasures.
The standard practice is to disable the logging from the application's settings/config file, or to move the whole offending folder to RAM. It means any write in that folder will go in RAM instead than on disk in a completely magical way, but this also means that if the NAS reboots or crashes you will lose all modifications you made to those folders.
Since on average it's logging or temporary files, it's no big loss.
If you want to save logs or some folder contents from the tmpfs you made above have a look at this script from Solo0815 [Tutorial][Experimental]Reducing OMV's disk writes, also to install it on USB flash
Open /etc/fstab with a text editor
if yu are already root don't write sudo.
this is an example fstab
# /etc/fstab: static file system information.
# <file system> <mount point> <type> <options> <dump> <pass>
/dev/sda1 / ext2 noatime,errors=remount-ro 0 1
tmpfs /tmp tmpfs defaults,noatime 0 0
Add the noatime option to the root partition, delete any "realtime" option. This turns off the logging of the last access time of a file (that causes writes every time a file is read)
As you see in the example fstab I added only /tmp folder as a tmpfs (ram disk).
Adding other folders tends to cause problems, sadly. For example, adding /var/cache and /var/log would result in annoyances from apt and nginx and probably something else that will fail horribly or crash if they don't find their things and log files.
We need a script that mounts the appropriate folders as tmpfs and fills them with data and directory structure from a backup, then at shutdown takes the data from the tmpfs and makes a backup on disk (or not, it really matters only when booting).
Like explained here https://www.debian-administrat…/661/A_transient_/var/log
Thankfully, there is a premade package of scripts called fs2ram that does that automagically for a list of folders in its config. Not available on Wheezy, but available in Sid, here you find the .deb, install manually. https://packages.debian.org/sid/admin/fs2ram
from terminal it's this (if the package is updated in the repos and the link breaks, use the link above to find the correct download link to use):
wget http://ftp.us.debian.org/debian/pool/main/f/fs2ram/fs2ram_0.3.12_all.deb
sudo dpkg -i fs2ram*
(if you are already root don't write sudo)
Once installed it will ask you if you prefer to save logs at shutdown or just to rebuild folder structure on boot in the tmpfs. Choose the one you prefer.
Time to work on folder /var/lib/openmediavault/rrd and the /var/spool
All this stuff goes directly in fs2ram's own config file, that looks suspiciously like fstab.
to open it and the follwoing is an example:
#<file system> <mount point> <script> <script option> <type> <options>
tmpfs /var/log keep_file_content - tmpfs
tmpfs /var/tmp keep_file_content - tmpfs
tmpfs /var/lib/openmediavault/rrd keep_file_content - tmpfs
tmpfs /var/spool keep_file_content - tmpfs
tmpfs /var/lib/rrdcached/ keep_file_content - tmpfs
tmpfs /var/lib/monit keep_file_content - tmpfs
tmpfs /var/lib/php5 keep_folder_structure - tmpfs
Spot the differences between this list and the standard list in your config file.
You could theoretically add also tmpfs /var/cache keep_file_content - tmpfs, but I find it unnecessary.
I commented it out because I have only 512 MB of ram in my NAS, and /var/cache contains the apt-get package cache (and little else).
If you want to keep it in a tmpfs make sure you are running apt-get autoclean in a cronjob, or you are keeping the package cache size in check somehow.
Old tutorials usually talk about symlinking the mtab with /proc/mounts, but this was already done upstream in Debian, so we don't need to do anything about it.
Done. Reboot the system for changes to take effect, and if it does boot up again and is still operational, pat yourself on the shoulder, Good Job!
Look in logs to see if f2ram is reporting errors about some folder, and if there is any program complaining that it cannot start because it needs something.
Some programs/services will complain saying they did not find file X, check if the file has been created or not, those error reports are usually just a warning.
If I missed something or you have a file that I don't have (quite possible, as I'm running OMV on a Zyxel nsa325v2, ARM debian) please post below and I'll try to keep the OP updated.