2 minutes
Speed Up I/O Performance with RAMDisk and LVM Cache
In this blog article, we will discuss various methods to speed up I/O performance and ultimately settle on using LVM to mount a fast I/O device with a RAMDisk as cache. This approach is beneficial when you don’t care about retaining data in the location between reboots.
Options Considered
- Only use RAM (i.e., tmpfs of 20 or 30GB): This option has the problem that if RAM is not enough, the build will fail.
- Use larger tmps (double the amounts above) and use the fast I/O location as a swap: The issue with this option is that if the system needs to use the swap, the complete OS could become laggy and unresponsive, affecting the build times.
- Concatenate RAM with Fast I/O using LVM: This approach does not guarantee that the filesystem will write first on RAM.
- Use LVM to mount the Fast I/O with RAMDisk as cache: This is the best approach among the options considered, but further research on the options of LVM is needed.
We will focus on option 4 for the rest of this article.
Implementation
Here’s a script that implements option 4:
To make sure the script runs at startup, you can add it to /etc/rc.local
. However, it is better to write your own service for this purpose.
Conclusion
Using LVM to mount a fast I/O device with a RAMDisk as cache is an effective method to speed up I/O performance. It is essential to ensure that the system is set up correctly to achieve the best results. Consider writing your own service instead of using rc.local
for a more robust implementation.