9.5. Enabling dm-writecache caching for a logical volume
This procedure enables caching of write I/O operations to a logical volume using the dm-writecache
method.
Conditions préalables
-
A slow logical volume that you want to speed up using
dm-writecache
exists on your system. - The volume group that contains the slow logical volume also contains an unused physical volume on a fast block device.
- If the slow logical volume is active, deactivate it.
Procédure
If the slow logical volume is active, deactivate it:
# lvchange --activate n <vg>/<main-lv>
Replace the following values:
vg
- The volume group name
main-lv
- The name of the slow logical volume
Create a deactivated
cachevol
volume on the fast device:# lvcreate --activate n --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.5. Creating a deactivated
cachevol
volume# lvcreate --activate n --size 5G --name fastvol vg /dev/sdf WARNING: Logical volume vg/fastvol not zeroed. Logical volume "fastvol" created.
Attach the
cachevol
volume to the main logical volume to begin caching:# lvconvert --type writecache --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.6. Attaching the
cachevol
volume to the main LV# lvconvert --type writecache --cachevol fastvol vg/main-lv Erase all existing data on vg/fastvol? [y/n]?: y Using writecache block size 4096 for unknown file system block size, logical block size 512, physical block size 512. WARNING: unable to detect a file system block size on vg/main-lv WARNING: using a writecache block size larger than the file system block size may corrupt the file system. Use writecache block size 4096? [y/n]: y Logical volume vg/main-lv now has writecache.
Activate the resulting logical volume:
# lvchange --activate y <vg/main-lv>
Replace the following values:
vg
- The volume group name
main-lv
- The name of the slow logical volume
Verification steps
Examine the newly created devices:
# lvs --all --options +devices vg LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert Devices main-lv vg Cwi-a-C--- 500.00m [fastvol_cvol] [main-lv_wcorig] 0.00 main-lv_wcorig(0) [fastvol_cvol] vg Cwi-aoC--- 252.00m /dev/sdc1(0) [main-lv_wcorig] vg owi-aoC--- 500.00m /dev/sdb1(0)
Ressources supplémentaires
-
lvmcache(7)
man page