9.4. Enabling dm-cache caching with a cachepool for a logical volume
This procedure enables you to create the cache data and the cache metadata logical volumes individually and then combine the volumes into a cache pool.
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
cachepool
volume on the fast device:lvcreate --type cache-pool --size <cachepool-size> --name <fastpool> <vg /dev/fast>
# lvcreate --type cache-pool --size <cachepool-size> --name <fastpool> <vg /dev/fast>
Copy to Clipboard Copied! Replace the following values:
cachepool-size
-
The size of the
cachepool
, such as5G
fastpool
-
A name for the
cachepool
volume vg
- The volume group name
/dev/fast
The path to the fast block device, such as
/dev/sdf1
NoteYou can use
--poolmetadata
option to specify the location of the pool metadata when creating the cache-pool.Exemple 9.3. Creating a
cachepool
volumelvcreate --type cache-pool --size 5G --name fastpool vg /dev/sde
# lvcreate --type cache-pool --size 5G --name fastpool vg /dev/sde Logical volume "fastpool" created.
Copy to Clipboard Copied!
Attach the
cachepool
to the main logical volume to begin caching:lvconvert --type cache --cachepool <fastpool> <vg/main>
# lvconvert --type cache --cachepool <fastpool> <vg/main>
Copy to Clipboard Copied! Replace the following values:
fastpool
-
The name of the
cachepool
volume vg
- The volume group name
main
The name of the slow logical volume
Exemple 9.4. Attaching the
cachepool
to the main LVlvconvert --type cache --cachepool fastpool vg/main
# lvconvert --type cache --cachepool fastpool vg/main Do you want wipe existing metadata of cache pool vg/fastpool? [y/n]: y Logical volume vg/main is now cached.
Copy to Clipboard Copied!
Verification steps
Examine the newly created devicevolume with the
cache-pool
type:lvs --all --options +devices <vg>
# lvs --all --options +devices <vg> LV Pool Type Devices [fastpool_cpool] cache-pool fastpool_pool_cdata(0) [fastpool_cpool_cdata] linear /dev/sdf1(4) [fastpool_cpool_cmeta] linear /dev/sdf1(2) [lvol0_pmspare] linear /dev/sdf1(0) main [fastpoool_cpool] cache main_corig(0) [main_corig] linear /dev/sdf1(O)
Copy to Clipboard Copied!