If I have an SSD and a hard disk in a system, can the SSD act as cache for the hard disk?
bcache might be what you are looking for. It can act as write through or write back cache.
ZFS and Btrfs also have features to put more often used blocks on flash storage.
If you have a set of files for which you need low latency, you can establish a RAID-1 volume that mirrors the SSD content on a hard disk. Declare the hard disk component as “write-mostly”, so that the SSD will be favored when reading. For example, if sda
is your SSD and sdb
is your hard disk, create a partition sda1
that covers the whole drive, create a partition sdb1
of the same size, and create a RAID volume with
mdadm --create -l 1 -n 2 /dev/md0 /dev/sda1 --write-mostly /dev/sdb1
There is flashcache. It is used by Facebook to accelerate DB-storage systems.
I haven't tried it yet, so your mileage may vary.