LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Can I use a solid state drive as a cache for a larger hard disk? (https://www.linuxquestions.org/questions/linux-general-1/can-i-use-a-solid-state-drive-as-a-cache-for-a-larger-hard-disk-687904/)

jcreigh 12-02-2008 10:55 PM

Can I use a solid state drive as a cache for a larger hard disk?
 
Hi all,

I'm interested in the idea of using a solid state drive to speed up my day-to-day computing, but I can't afford to use a solid state drive for all my data, and I don't want to have to manually pick and choose what goes on and what doesn't.

So I'm wondering if it's possible to get a smallish solid state drive (say, 32GB or 64GB) and use it transparently as a cache for a larger (eg, 500GB or so), cheaper traditional hard drive. I'm envisioning some sort of kernel driver that sets up a virtual block device based on the SSD and the hard disk. Writes would go though to the hard disk, but reads would check a cache that would be maintained on the SSD before hitting the hard disk. Cache misses would cause the least recently used block in the cache the be dropped and replaced with the block that was just read. Or something like that.

Does anybody know of anything that does this? Or have any pointers for where to look? I've googled around, but to no avail.

Thanks,

Jason

jschiwal 12-02-2008 11:28 PM

Writing to a solid state drive would be slower than on a real hard drive. Also, you want to limit the number of writes to a solid state drive so using one as a cache would reduce the lifetime of the drive. The distro's for the eeePC don't have a swap file and use RAM for cache to reduce the number of writes.

It would make sense to use a solid state drive for static system directories such as /bin, /sbin/, /lib, /sbin, /usr/sbin, etc. These directories are mounted so that only root can write to them, and are only written to when you install a package. According to the LFS, these directories can even be mounted static-shared. They make ideal candidates for a solid state drive with faster read times and no spin-up time.

A compromise might be to use unionfs and copy files with old create timestamps, and recent access times (that are frequently read), and copy them to the solid-state layer. This would create a read-cache for files on the hard drive that aren't written often.
http://www.linuxjournal.com/article/7714
You may need to install an -mm kernel or manually patch your kernel's source to add unionfs, but with the popularity of the eeePC and it's use in Knoppix, it may be included in the mainline kernel.
Some of the papers on the unionfs home page may describe something similar to what you described.


All times are GMT -5. The time now is 06:36 PM.