Can I prevent ZFS writing to HDD by caching write requests during a time period?
4
votes
0
answers
155
views
### Background
I have recently built a NAS/homelab, with one fairly large SSD for system and 3 HDDs in ZFS + RAID-Z1 for data. The setup works great, and I expect it to be on 24/7.
However, some services on the NAS would read and write to data partitions on the HDDs periodically (e.g. databases in monitoring software). This causes the HDDs to spin up and down and make noises, especially during the night, which is somewhat annoying. I _can_ try to switch to a noise-proof case or something like that, but I would like to see if there's a software solution.
### The question
Can I let the SSD behave like a write-back cache during the night and flush them in the morning, so the HDDs remain mostly idle during the night?
I'm fine with the lower integrity for data generated during the night.
AFAIK, L2ARC in ZFS does not cache write requests. I've heard of bcache which can hold write requests in SSD for a long time before flushing them to HDDs, but seems like there's compatibility problem between it and ZFS. ([One source](https://loskoderos.com/2023/05/25/hybrid-storage-with-zfs-bcache-luks/) recommends LUKS as an intermediate layer to avoid this.) Is using ZFS over bcache a good idea, and how should I configure it if yes?
### Similar questions
[Caching write changes on SSD to avoid HDD spin-up? ZFS, but (probably) not L2ARC](https://unix.stackexchange.com/questions/122386/caching-write-changes-on-ssd-to-avoid-hdd-spin-up-zfs-but-probably-not-l2arc) -- I would rather like an automated solution, and I don't have a clear pattern on what's being written. And the question is 10 years old.
[https://unix.stackexchange.com/questions/656856/use-ssds-as-persistent-buffer-for-hdds-to-decrease-power-usage](https://unix.stackexchange.com/questions/656856/use-ssds-as-persistent-buffer-for-hdds-to-decrease-power-usage) -- Whoops, this doesn't have an answer.
Asked by Rynco Maekawa
(141 rep)
Sep 21, 2024, 01:23 PM