Cache logical volumes with dm-cache

When caching an LV with dm-cache, a cache pool stores cached data and metadata. The cache pool is associated with a specific LV. Frequently accessed blocks are cached, while less frequently accessed blocks remain on slower storage.

Before you begin

  • Administrative access.

Procedure

  1. Display the LV you want to cache and its volume group:
    # lvs -o lv_name,vg_name
      LV                   VG
      LogicalVolumeName    VolumeGroupName
  2. Create the cache pool:
    # lvcreate --type cache-pool --name CachePoolName --size Size VolumeGroupName /FastDevicePath

    Replace CachePoolName with the name of the cache pool. 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.

  3. Attach the cache pool to the LV:
    # lvconvert --type cache --cachepool VolumeGroupName/CachePoolNameVolumeGroupName/LogicalVolumeName

Results

  • Verify that the LV is now cached:
    # lvs -o lv_name,pool_lv
      LV                   Pool
      LogicalVolumeName    [CachePoolName_cpool]