9.3. Enabling dm-cache caching for a logical volume
This procedure enables caching of commonly used data on a logical volume using the dm-cache
method.
Conditions préalables
-
A slow logical volume that you want to speed up using
dm-cache
exists on your system. - The volume group that contains the slow logical volume also contains an unused physical volume on a fast block device.
Procédure
Create a
cachevol
volume on the fast device:# lvcreate --size cachevol-size --name <fastvol> <vg> </dev/fast-pv>
Replace the following values:
cachevol-size
-
The size of the
cachevol
volume, such as5G
fastvol
-
A name for the
cachevol
volume vg
- The volume group name
/dev/fast-pv
The path to the fast block device, such as
/dev/sdf
Exemple 9.1. Creating a
cachevol
volume# lvcreate --size 5G --name fastvol vg /dev/sdf Logical volume "fastvol" created.
Attach the
cachevol
volume to the main logical volume to begin caching:# lvconvert --type cache --cachevol <fastvol> <vg/main-lv>
Replace the following values:
fastvol
-
The name of the
cachevol
volume vg
- The volume group name
main-lv
The name of the slow logical volume
Exemple 9.2. Attaching the
cachevol
volume to the main LV# lvconvert --type cache --cachevol fastvol vg/main-lv Erase all existing data on vg/fastvol? [y/n]: y Logical volume vg/main-lv is now cached.
Verification steps
Verify if the newly created logical volume has
dm-cache
enabled:# lvs --all --options +devices <vg> LV Pool Type Devices main-lv [fastvol_cvol] cache main-lv_corig(0) [fastvol_cvol] linear /dev/fast-pv [main-lv_corig] linear /dev/slow-pv
Ressources supplémentaires
-
lvmcache(7)
man page