If you're using ZFS on Linux as part of a home NAS solution, you might want to make your disks sleep when they are not in use.
Here are the steps:
Keep cron jobs in check
Check your crontab,
/etc/cron.d directories. Neutralize or modify any cron jobs that take place more than one time a day, so they happen at the same time.
Check for daemons that do periodic scans
Make them defer their scans for later, or configure them so they scan all together at the same time.
Disable unnecessary daemons
Mount all your filesystems
For regular filesystems, you can set mount option
fstab. For ZFS, a
zfs set atime=off poolname command will accomplish the same.
Find files modified in the last day or so
Now that you have no reason to worry about access time updates causing disk writes, you can issue this command:
find / -mtime -1
find command will give you an idea of what files have been modified in the last day. Check for on-disk directories or files that are modified recently (in other words, ignore anything coming from pseudo-filesystems like
/sys). We'll be moving them to flash storage.
Relocate directories and files to non-rotating media
Get a cheap USB drive (does not need to be big) and format it as
ext4 (technically, you could set up another ZFS pool there too). Then, set it to be mounted in
/var/volatile on your
You can now move directories that contain frequently modified files there. After you're done moving those directories, you can symlink them from their original location. So, for example, you would move
/var/volatile/log, then creating a symbolic link to
At this point, it would be wise to make a cron job to nightly back the contents of this USB drive up (think
rsync -a) to a
backups directory somewhere in your pool.
OK. If you've moved the most frequently modified files to
/var/volatile, your disks will be idle unless you are actually using your file server. Now it's time to take advantage of that idleness.
Finally, tell your disks to power off when they're idle
/etc/rc.d/rc.local file, you can add one of these commands for each one of your rotating disks (
hdparm -S 120 /dev/sda
-S 120 parameter tells the disk to go to sleep every ten minutes. So, if nothing has read or written to the disk for ten minutes, the disk will enter a non-rotating, very low-power mode.