SSD as Cache for Filesystem (e.g. on HDD or any other)

cachefilesystemshard-disk

Can I use SSD (e.g. 512GiB) to be cache for my filesystem (e.g. 16TiB) ?

I'd like to avoid my disks on NAS to spin up every day, as when my computers rsync to it, only file sizes, timestamps are checks, plus few data is actually updated (so 512GiB could allow, for waking up harddrives much less often, only for "SSD->HDD" "flush").

Any ideas how to set it up?

Please give me hints of potential ambiguities in question.

(Of course given "HDDs backed" filesystem is example, it could be NFS of any other)

Currently two filesystems I might like to "cache with ssd" to avoid disks spin ups, are: EXT4 on LVM, and Btrfs.

Use case:
I have computer at room, that serves as Linux NAS.
During day other computers sync to it periodically, so it's disks are spinning, falling a sleep/quiet at night. Most of time, computers rsync only few changed files and check sizes and timestamps of others, as usually very little new data (

Best Answer

Use ZFS as the underlying filesystem for your HDD drives. Then simply add the SSD as cache.

From man zpool:

Cache Devices

Devices can be added to a storage pool as "cache devices". These devices provide an additional layer of caching between main memory and disk. For read-heavy workloads, where the working set size is much larger than what can be cached in main memory, using cache devices allow much more of this working set to be served from low latency media. Using cache devices provides the greatest performance improvement for random read-workloads of mostly static content.

Be aware that frequent starting/stopping HDDs considerably reduces their lifetime.

Related Question