I want to build a NAS that is as quiet, efficient and cool as possible.
In this scenario, I have the following parts:
-4 SATA connections to the motherboard.
-2 Hard drives, one is 1TB, the other is 900GB
-2 SSD’s, one is 220GB, the other is 120GB.
-All the data must be still accessible, even when one of the drives or ssd’s fails.
-The HD’s must be kept idle, (not spinning) as long as possible.
-No data corruption after a drive or ssd decides to return incorrect data.
-The NAS does not have to be the fastest NAS in the world.
-It’s OK to wait a few seconds until the HDD’s have spun up when data is accessed that’s not on the SSD’s.
How I imagine this to work:
I would like to use the 2 hard drives as bulk storage, and the 2 SSD’s as cache. Let’s pretend both SSD’s are empty, and the hard drives each hold a copy of the data. When new data is written to the NAS, it is written to both SSD’s. if one of the SSD’s is (almost) full, the hard drives spin up, and all of the data on the SSD’s is transferred to the hard drives. Half of the data (the least accessed written data) is then removed from the SSD’s, so more data from the client can be stored on the SSD’s
When the client requests data that is stored on the SSD’s, the HD’s are kept idle. When the client requests data that’s not on one of the SSD’s, one of the hard drives is woken up. (not both hard drives, only one). Then the data that is requested is transferred from the hard drive to the client. Next the data that is adjacent to the data that the client requested (for instance the complete file the client is working on, all the files in that directory, or the next few episodes of the series the client is watching) are then transferred to the read cache on the biggest of the SSD’s
On the 2 SSD’s there’s a raid 1 (mirrored) btrfs filesystem of 120GB. This is the write cache.
On the biggest SSD there’s also a 120GB btrfs filesystem of 120GB. this is the read cache.
On the 2 HDD’s there’s a raid 1 (mirrored) btrfs filesystem of 900GB. the 100GB of the biggest drive is not used.
2 instances of bcache are used to handle the read and the write caching.
Each hard drive has its own SSD cache (managed by bcache). Then both HDD+SSD stacks are then put into a btrfs raid 1 (mirrored) array. Hopefully bcache can be setup to not write to the hard drives until, say, 60GB of data is dirty, or until there’s a read cache miss.
Which of the two implementations is the best? Or is there a third option that is better?
Is btrfs the best filesystem to use in this scenario?
Is bcache able to not only cache the recently read data, but also to cache the adjacent data?
Is there something useful that can be done with the 100GB free space of the biggest hard drive?