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

  1. Create a cachepool volume on the fast device:

    # lvcreate --type cache-pool --size <cachepool-size> --name <fastpool> <vg /dev/fast>
    Copy to Clipboard

    Replace the following values:

    cachepool-size
    The size of the cachepool, such as 5G
    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

    Note

    You can use --poolmetadata option to specify the location of the pool metadata when creating the cache-pool.

    Exemple 9.3. Creating a cachepool volume

    # lvcreate --type cache-pool --size 5G --name fastpool vg /dev/sde
    Logical volume "fastpool" created.
    Copy to Clipboard
  2. Attach the cachepool to the main logical volume to begin caching:

    # lvconvert --type cache --cachepool <fastpool> <vg/main>
    Copy to Clipboard

    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 LV

    # 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

Verification steps

  • Examine the newly created devicevolume with the cache-pool type:

    # 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
Retour au début
Red Hat logoGithubredditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance. Découvrez nos récentes mises à jour.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez le Blog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

Theme

© 2025 Red Hat