Путеводитель по Руководству Linux

  User  |  Syst  |  Libr  |  Device  |  Files  |  Other  |  Admin  |  Head  |



   lvmcache    ( 7 )

кеширование LVM (LVM caching)

  Name  |  Description  |    Usage    |  Options  |  See also  |

Использование (Usage)

1. Identify main LV that needs caching The main LV may already exist, and is located on larger, slower devices. A main LV would be created with a command like:

# lvcreate -n main -L Size vg /dev/slow_hhd

2. Identify fast LV to use as the cache A fast LV is created using one or more fast devices, like an SSD. This special LV will be used to hold the cache:

# lvcreate -n fast -L Size vg /dev/fast_ssd

# lvs -a LV Attr Type Devices fast -wi------- linear /dev/fast_ssd main -wi------- linear /dev/slow_hhd

3. Start caching the main LV To start caching the main LV, convert the main LV to the desired caching type, and specify the fast LV to use as the cache:

using dm-cache (with cachepool):

# lvconvert --type cache --cachepool fast vg/main

using dm-cache (with cachevol):

# lvconvert --type cache --cachevol fast vg/main

using dm-writecache (with cachevol):

# lvconvert --type writecache --cachevol fast vg/main

For more alteratives see: dm-cache command shortcut dm-cache with separate data and metadata LVs

4. Display LVs Once the fast LV has been attached to the main LV, lvm reports the main LV type as either cache or writecache depending on the type used. While attached, the fast LV is hidden, and renamed with a _cvol or _cpool suffix. It is displayed by lvs -a. The _corig or _wcorig LV represents the original LV without the cache.

using dm-cache (with cachepool):

# lvs -ao+devices LV Pool Type Devices main [fast_cpool] cache main_corig(0) [fast_cpool] cache-pool fast_pool_cdata(0) [fast_cpool_cdata] linear /dev/fast_ssd [fast_cpool_cmeta] linear /dev/fast_ssd [main_corig] linear /dev/slow_hhd

using dm-cache (with cachevol):

# lvs -ao+devices

LV Pool Type Devices main [fast_cvol] cache main_corig(0) [fast_cvol] linear /dev/fast_ssd [main_corig] linear /dev/slow_hhd

using dm-writecache (with cachevol):

# lvs -ao+devices

LV Pool Type Devices main [fast_cvol] writecache main_wcorig(0) [fast_cvol] linear /dev/fast_ssd [main_wcorig] linear /dev/slow_hhd

5. Use the main LV Use the LV until the cache is no longer wanted, or needs to be changed.

6. Stop caching To stop caching the main LV and also remove unneeded cache pool, use the --uncache:

# lvconvert --uncache vg/main

# lvs -a LV VG Attr Type Devices main vg -wi------- linear /dev/slow_hhd

To stop caching the main LV, separate the fast LV from the main LV. This changes the type of the main LV back to what it was before the cache was attached.

# lvconvert --splitcache vg/main

# lvs -a LV VG Attr Type Devices fast vg -wi------- linear /dev/fast_ssd main vg -wi------- linear /dev/slow_hhd

7. Create a new LV with caching A new LV can be created with caching attached at the time of creation using the following command:

# lvcreate --type cache|writecache -n Name -L Size --cachedevice /dev/fast_ssd vg /dev/slow_hhd

The main LV is created with the specified Name and Size from the slow_hhd. A hidden fast LV is created on the fast_ssd and is then attached to the new main LV. If the fast_ssd is unused, the entire disk will be used as the cache unless the --cachesize option is used to specify a size for the fast LV. The --cachedevice option can be repeated to use multiple disks for the fast LV.