<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Lance Albertson &#187; bar</title>
	<atom:link href="http://www.lancealbertson.com/tag/bar/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.lancealbertson.com</link>
	<description>Musings of a UNIX SysAdmin, jazz lover, and wine/beer snob</description>
	<lastBuildDate>Thu, 10 Jun 2010 16:37:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Adding a simple progress bar to dd</title>
		<link>http://www.lancealbertson.com/2009/04/adding-a-simple-progress-bar-to-dd/</link>
		<comments>http://www.lancealbertson.com/2009/04/adding-a-simple-progress-bar-to-dd/#comments</comments>
		<pubDate>Tue, 28 Apr 2009 05:35:27 +0000</pubDate>
		<dc:creator>lance</dc:creator>
				<category><![CDATA[gentoo]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[bar]]></category>
		<category><![CDATA[dd]]></category>
		<category><![CDATA[kvm]]></category>
		<category><![CDATA[lvm]]></category>
		<category><![CDATA[migration]]></category>

		<guid isPermaLink="false">http://test.lancealbertson.com/?p=93</guid>
		<description><![CDATA[I recently ran into an issue where I wanted to move several KVM based virtual machines from one server to another server. There's several ways you can accomplish this depending on what you want to do. In my case I was using LVM for the disk backend, so simply copying the disk image files wasn't [...]]]></description>
			<content:encoded><![CDATA[<p>I recently ran into an issue where I wanted to move several <a href="http://www.linux-kvm.org/page/Main_Page">KVM</a> based virtual machines from one server to another server. There's several ways you can accomplish this depending on what you want to do. In my case I was using <a href="http://en.wikipedia.org/wiki/Logical_Volume_Manager_(Linux)">LVM</a> for the disk backend, so simply copying the disk image files wasn't an option. It boiled down to two basic options.</p>
<ul>
<li>Put system in single-user mode, rsync the contents over, and reinstall grub</li>
<li>Use dd and copy the whole LVM volume over piped through ssh</li>
</ul>
<p>The advantage using the rsync method is that you're only copying the files you need over, thus less data transfer happens. But then you run into needing to re-run grub (which generally isn't a problem). In addition, if you're using LVM within the LVM volume for the VM and the volume group is named the same, you run into some interesting issues. The advantage for using <strong>dd</strong> is that you can get a literal copy of the disk image and just start the VM back up without any other steps. Of course, this will only work if the volumes are the same on both ends.</p>
<p>So I decided to go with dd but ran into a problem of seeing the progress of a 15G volume copy. I did some digging around and found a <a href="http://fosswire.com/post/2007/8/command-line-progress-bar-a-progress-bar-for-dd/">blog post</a> that mentioned using a command line application called '<a href="http://clpbar.sourceforge.net/">bar</a>' so I decided to give it a shot! Its a fairly simple application that just creates a basic progress bar based on the data being piped into it. If you're running Gentoo, the package is called <strong>app-admin/bar</strong>.</p>
<p>Here's the command I ended up running:</p>
<pre class="brush: bash;">
$ dd if=/dev/lvm/cholula-disk | bar -s 15g | \
    ssh -c arcfour $host &quot;dd of=/dev/lvm/cholula-disk&quot;</pre>
<p>When ran, it gives you output similar to:</p>
<pre class="brush: bash;">
6.0GB at   17.9MB/s  eta:   0:08:32   40 [=========================                 ]
</pre>
<p>The downside is that you need to specify the block device size before hand, but for something simple like this its quite nice. Of course I could just use one of the many dd forks out there which include progress bars but this is quick, dirty, and simple!</p>
<p>I used the arcfour cipher mainly to reduce the CPU overhead and increase the throughput, but you should probably never use this cipher on an untrusted network as it does have weaknesses. I didn't try doing throughput tests on other ciphers, but it would be interesting. It took me approximately 10-12 minutes to copy a 15G volume over a gigabit network which isn't too bad.</p>
<p>Another trick you can do is utilitize the LVM snapshot feature and create a snapshot of the running volume. If any data changes on the volume, it won't be copied over obviously, but it will at least let you do a cold "live" migration of sorts.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.lancealbertson.com/2009/04/adding-a-simple-progress-bar-to-dd/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
