LVM

Read/Write Cache

Enable Cache

Create ${CACHE_LV}:

lvcreate --type raid1 -m 1 -n ${CACHE_LV} ${VG} ${CACHE_PV1} ${CACHE_PV2}

Enable cache:

lvconvert --type cache --cachepool ${CACHE_LV} --cachemode writeback --chunksize 256 ${VG}/${LV}

Tip

  • Only use ~75% of an SSD to ensure good performance.

  • Run TRIM on the empty space (blkdiscard(8)).

Disable Cache

lvconvert --splitcache ${VG}/${LV}

Run Raid Check

lvchange --syncaction check ${VG}/${LV}

Tip

You can use --maxrecoveryrate ${RATE} to reduce the impact on performance.

Rate is per device. Default unit is KiB/s/device.