/post/2014-08-16-lvcache-a-tool-for-managing-lv/index.html
HTML | 308 lines | 227 code | 80 blank | 1 comment | 0 complexity | 532cc545ad7a83178df6b0c9d76b8d93 MD5 | raw file
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>lvcache: a tool for managing LVM caches · The Odd Bit</title>
- <meta name="description" content="Until recently I had a bcache based setup on my laptop, but when forced by circumstance to reinstall everything I spent some time looking for alternatives that were less disruptive to configure on an existing system.
- I came across Richard Jones' article discussing the recent work to integrate dm-cache into LVM. Unlike bcache and unlike using dm-cache directly, the integration with LVM makes it easy to associate devices with an existing logical volume.">
- <meta name="HandheldFriendly" content="True">
- <meta name="MobileOptimized" content="320">
- <meta name="generator" content="Hugo 0.88.0" />
- <meta name="robots" content="index,follow">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
-
-
-
- <link rel="stylesheet" href="https://blog.oddbit.com/dist/style.min.81747fa30e7c939c160ea84909a818dc1b99d7e662edf55326bd32a4510c9eb5.css">
- <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,600,700,300&subset=latin,cyrillic-ext,latin-ext,cyrillic">
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
-
- <!-- alternate output formats -->
- <link rel="stylesheet" href="/css/oddbit.css">
- <link rel="stylesheet" href="/css/sx.css">
- <link rel="stylesheet" href="/css/pull-request.css">
- <link rel="stylesheet" href="/css/archive.css">
- <link rel="stylesheet" href="/css/syntax.css">
-
- </head>
- <body>
-
- <div id="wrapper">
- <header class="site-header">
- <div class="container">
- <div class="site-title-wrapper">
-
- <h1 class="site-title">
- <a title="The Odd Bit" href="https://blog.oddbit.com/">The Odd Bit</a>
- </h1>
-
- <a class="button-square" href="https://blog.oddbit.com/rss.xml"><i class="fa fa-rss"></i></a>
-
- <a class="button-square button-social hint--top" data-hint="Twitter" title="Twitter" href="https://twitter.com/larsks" rel="me">
- <i class="fa fa-twitter"></i>
- </a>
-
-
-
-
- <a class="button-square button-social hint--top" data-hint="Github" title="Github" href="https://github.com/larsks" rel="me">
- <i class="fa fa-github-alt"></i>
- </a>
-
-
- <a class="button-square button-social hint--top" data-hint="Stack Overflow" title="Stack Overflow" href="https://stackoverflow.com/users/147356/larsks" rel="me">
- <i class="fa fa-stack-overflow"></i>
- </a>
-
-
-
-
- </div>
- <div class="donate">
- If you find something here useful or interesting, you can
- <a href="https://www.buymeacoffee.com/oddbit">buy me a coffee</a>!
- </div>
- <ul class="site-nav">
-
- <li class="site-nav-item">
- <a title="Home" href="/">Home</a>
- </li>
- <li class="site-nav-item">
- <a title="Categories" href="/categories">Categories</a>
- </li>
- <li class="site-nav-item">
- <a title="Tags" href="/tags">Tags</a>
- </li>
- <li class="site-nav-item">
- <a title="Archives" href="/archives">Archives</a>
- </li>
- <li class="site-nav-item">
- <a title="Answers" href="/about/stackoverflow/">Answers</a>
- </li>
- <li class="site-nav-item">
- <a title="GPG Key" href="/about/gpg/">GPG Key</a>
- </li>
- </ul>
- </div>
- </header>
- <div id="container">
- <div class="container">
- <article class="post-container" itemscope="" itemtype="http://schema.org/BlogPosting">
- <header class="post-header">
- <h1 class="post-title" itemprop="name headline">lvcache: a tool for managing LVM caches</h1>
-
- <p class="post-date post-line">
- <span>Published <time datetime="2014-08-16" itemprop="datePublished">Sat, Aug 16, 2014</time></span>
- <span>by</span>
- <span itemscope="" itemprop="author" itemtype="https://schema.org/Person">
- <span itemprop="name">
- <a href="/about/" itemprop="url" rel="author">Lars Kellogg-Stedman</a>
- </span>
- </span>
- </p>
-
- </header>
- <div class="post-content clearfix" itemprop="articleBody">
-
-
- <p>Until recently I had a <a href="http://bcache.evilpiepirate.org/">bcache</a> based setup on my laptop, but when
- forced by circumstance to reinstall everything I spent some time
- looking for alternatives that were less disruptive to configure on an
- existing system.</p>
- <p>I came across <a href="http://rwmj.wordpress.com/2014/05/22/using-lvms-new-cache-feature/">Richard Jones' article</a> discussing the recent work to
- integrate <a href="https://en.wikipedia.org/wiki/Dm-cache">dm-cache</a> into <a href="http://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)">LVM</a>. Unlike <em>bcache</em> and unlike using
- <em>dm-cache</em> directly, the integration with LVM makes it easy to
- associate devices with an existing logical volume.</p>
- <p>I have put together a small tool called <a href="https://github.com/larsks/lvcache">lvcache</a> that simplies the
- process of:</p>
- <ul>
- <li>Creating and attaching cache volumes</li>
- <li>Detaching and removing cache volumes</li>
- <li>Getting cache statistics for logical volumes</li>
- <li>Listing the cache status of all logical volumes</li>
- </ul>
- <p>With <code>lvcache</code> installed, you can run (as root) the following command
- to create a new cache volume that is 20% the size of your origin
- volume and attach it to the specified origin volume:</p>
- <pre><code># lvcache create myvg/home
- </code></pre>
- <p>You can control the size of the cache LV relative to the origin
- volume. To create a cache LV that is 40% the size of the origin
- volume:</p>
- <pre><code># lvcache create -% 40 myvg/home
- </code></pre>
- <p>You can query <code>dm-setup</code> for cache statistics with the <code>status</code>
- command (the <code>-H</code> translates raw bytes counts into human readable
- numbers with SI suffixes):</p>
- <pre><code># lvcache status -H myvg/home
- +-----------------------+------------------+
- | Field | Value |
- +-----------------------+------------------+
- | cached | True |
- | size | 32G |
- | cache_lv | home_cache |
- | cache_lv_size | 6G |
- | metadata_lv | home_cache_cmeta |
- | metadata_lv_size | 8M |
- | cache_block_size | 128 |
- | cache_utilization | 0/98304 |
- | cache_utilization_pct | 0.0 |
- | demotions | 0 |
- | dirty | 0 |
- | end | 62914560 |
- | features | 1 |
- | md_block_size | 8 |
- | md_utilization | 200/2048 |
- | md_utilization_pct | 9.765625 |
- | promotions | 0 |
- | read_hits | 0 |
- | read_misses | 0 |
- | segment_type | cache |
- | start | 0 |
- | write_hits | 0 |
- | write_misses | 0 |
- +-----------------------+------------------+
- </code></pre>
- <p>Because <code>lvcache</code> is using the <a href="http://cliff.readthedocs.org/en/latest/">cliff</a> framework, it is very easy to
- extract individual values from this list for graphing or monitoring
- purposes:</p>
- <pre><code># lvcache status tank.home -f value -c md_utilization_pct
- 9.765625
- </code></pre>
- <p>Or:</p>
- <pre><code># lvcache status tank.home -f shell
- cached="True"
- size="32G"
- cache_lv="nova_cache"
- cache_lv_size="6G"
- metadata_lv="nova_cache_cmeta"
- metadata_lv_size="8M"
- cache_block_size="128"
- cache_utilization="0/98304"
- cache_utilization_pct="0.0"
- demotions="0"
- dirty="0"
- end="62914560"
- features="1"
- md_block_size="8"
- md_utilization="200/2048"
- md_utilization_pct="9.765625"
- promotions="0"
- read_hits="0"
- read_misses="0"
- segment_type="cache"
- start="0"
- write_hits="0"
- write_misses="0"
- </code></pre>
- <p>This is a very rough tool right now, but it seems to get the job done
- on my system. If you do find this useful, let me know!</p>
- </div>
- <footer class="post-footer clearfix">
-
- <p class="post-tags">
- <span>Tagged:</span>
-
-
-
-
- <a href="https://blog.oddbit.com/tag/lvm/">lvm</a>,
-
-
-
-
- <a href="https://blog.oddbit.com/tag/cache/">cache</a>
-
-
- </p>
-
- <div class="share">
-
- <a class="icon-twitter" href="https://twitter.com/share?text=lvcache%3a%20a%20tool%20for%20managing%20LVM%20caches&url=https%3a%2f%2fblog.oddbit.com%2fpost%2f2014-08-16-lvcache-a-tool-for-managing-lv%2f"
- onclick="window.open(this.href, 'twitter-share', 'width=550,height=235');return false;">
- <i class="fa fa-twitter"></i>
- <span class="hidden">Twitter</span>
- </a>
-
-
-
-
- </div>
- </footer>
- <script src="https://utteranc.es/client.js"
- repo="larsks/blog.oddbit.com"
- issue-term="pathname"
- label="comment"
- theme="github-light"
- crossorigin="anonymous"
- async>
- </script>
- </article>
- </div>
- </div>
- </div>
- <footer class="footer">
- <div class="container">
- <div class="site-title-wrapper">
- <h1 class="site-title">
- <a title="The Odd Bit" href="https://blog.oddbit.com/">The Odd Bit</a>
- </h1>
- <a class="button-square button-jump-top js-jump-top" href="#">
- <i class="fa fa-angle-up"></i>
- </a>
- </div>
- <p class="footer-copyright">
- <span>© 2022 / Powered by <a href="https://gohugo.io/">Hugo</a></span>
- </p>
- <p class="footer-copyright">
- <span><a href="https://github.com/roryg/ghostwriter">Ghostwriter theme</a> By <a href="http://jollygoodthemes.com">JollyGoodThemes</a></span>
- <span>/ <a href="https://github.com/jbub/ghostwriter">Ported</a> to Hugo By <a href="https://github.com/jbub">jbub</a></span>
- </p>
- </div>
- </footer>
- <script src="https://blog.oddbit.com/js/jquery-1.11.3.min.js"></script>
- <script src="https://blog.oddbit.com/js/jquery.fitvids.js"></script>
-
-
- <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
-
-
- <script src="https://blog.oddbit.com/js/scripts.js"></script>
- </body>
- </html>