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-cacheexists 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
cachevolvolume on the fast device:lvcreate --size cachevol-size --name <fastvol> <vg> </dev/fast-pv>
# lvcreate --size cachevol-size --name <fastvol> <vg> </dev/fast-pv>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the following values:
cachevol-size-
The size of the
cachevolvolume, such as5G fastvol-
A name for the
cachevolvolume vg- The volume group name
/dev/fast-pvThe path to the fast block device, such as
/dev/sdfExemple 9.1. Creating a
cachevolvolumelvcreate --size 5G --name fastvol vg /dev/sdf
# lvcreate --size 5G --name fastvol vg /dev/sdf Logical volume "fastvol" created.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Attach the
cachevolvolume to the main logical volume to begin caching:lvconvert --type cache --cachevol <fastvol> <vg/main-lv>
# lvconvert --type cache --cachevol <fastvol> <vg/main-lv>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the following values:
fastvol-
The name of the
cachevolvolume vg- The volume group name
main-lvThe name of the slow logical volume
Exemple 9.2. Attaching the
cachevolvolume to the main LVlvconvert --type cache --cachevol fastvol vg/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.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification steps
Verify if the newly created logical volume has
dm-cacheenabled:Copy to Clipboard Copied! Toggle word wrap Toggle overflow