When caching LVs with dm-writecache, a cache layer is created between the logical volume and storage device. dm-writecache stores writes on faster media, such as SSDs, before writing them to primary storage. This improves write-intensive workload performance.
Procedure
-
Display the logical volume you want to cache and its volume group:
LV VG
LogicalVolumeName VolumeGroupName
-
Create a cache volume:
# lvcreate --name CacheVolumeName --size SizeVolumeGroupName /FastDevicePath
Replace CacheVolumeName with the name of the cache volume. Replace Size with the size for your cache pool. Replace VolumeGroupName with the name of the volume group. Replace /FastDevicePath with the path to your fast device, for example SSD or NVME.
-
Deactivate the cache volume:
# lvchange -an VolumeGroupName/CacheVolumeName
Replace VolumeGroupName with the name of the volume group. Replace CacheVolumeName with the name of the cache volume.
-
Attach the cache volume to the LV:
# lvconvert --type writecache --cachevol CacheVolumeName VolumeGroupName/LogicalVolumeName
Replace CacheVolumeName with the name of the cache volume. Replace VolumeGroupName with the name of the volume group. Replace LogicalVolumeName with the name of the logical volume.
Results
- Verify that the LV is now cached:
LV Pool
LogicalVolumeName [CacheVolumeName_cvol]