/dmcache-utils

Device mapper cache utilities

Primary LanguageShellGNU General Public License v2.0GPL-2.0

===============================
 Device mapper cache utilities
===============================

License: GPLv2+, see COPYING for details

This project provides few simple scripts to simplify the usage of
dmcache devices. These scripts are based on the work of Darrick
J. Wong [1]. They have been rewritten and simplified to better fit our
needs. I was also scared of getting my BIOS reflashed with rude
poetry [2].

[1]: http://djwong.org/docs/dmcache-tools.tar.gz
[2]: http://www.redhat.com/archives/dm-devel/2013-March/msg00057.html

Commands
========

dmc-load
--------

Load and activate dmcache devices defined in /etc/dmctab. Quite
naturally, this command must be executed before mounting cached
partitions. Hence, it's a good practice to set udev run it. See
86-dmc.rules.

Usage: dmc-load [NAME]

NAME - a name of the device mapper cache device defined in
       /etc/dmctab. If not given, load all dmctab entries.

dmc-unload
----------

Deactivate and unload dmcache devices defined in /etc/dmctab. This is a
logical counterpart of dmc-load and does reverse operations in reverse
order.

Usage: dmc-unload [NAME]

NAME - a name of the device mapper cache device defined in
       /etc/dmctab. If not given, unload all dmctab entries.

dmc-mklvm
---------

Format a disk with LVM partitions suitable for dmcache devices.

Usage: dmc-mklvm [-b CACHE_BLOCK_SIZE=512] VG PV

CACHE_BLOCK_SIZE - the size of cache blocks. This is used to calculate
                   the optimal size for the metadata device. Default
                   is 512 sectors.

VG - name for the volume group

PV - physical volume for the volume group, e.g. a disk, a disk
     partition, etc.

Setup example
=============

Assumptions:

- the cache disk (SSD-disk) is /dev/sda
- the cached partition is /dev/mapper/main-home
- 'cache-home' is the desired name for the cache volume group

Run::

  dmc-mklvm cache-home /dev/sda

Add the following entry to /etc/dmctab::

  cache-home /dev/cache-home/metadata /dev/cache-home/data /dev/mapper/main-home 512 0 default 0

Edit /etc/fstab to mount /home from the cache device by adding the following entry::

  /dev/mapper/cache-home   /home   ext4    defaults    0       2

Remember also to comment or remove the previous /home mount entry::

  #/dev/mapper/main-home  /home   ext4    defaults    0       2

Copy 86-dmc.rules to /lib/udev/rules.d if its not already there.