<?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>Daniel Hall&#039;s Website &#187; LVM</title>
	<atom:link href="http://www.danielhall.me/tag/lvm/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.danielhall.me</link>
	<description>Because the Internet doesn&#039;t have enough opinions already</description>
	<lastBuildDate>Thu, 29 Jul 2010 11:52:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>Oh My God &#8211; I broke my LVM</title>
		<link>http://www.danielhall.me/2009/08/oh-my-god-i-broke-my-lvm/</link>
		<comments>http://www.danielhall.me/2009/08/oh-my-god-i-broke-my-lvm/#comments</comments>
		<pubDate>Fri, 07 Aug 2009 22:04:25 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[LVM]]></category>
		<category><![CDATA[Recovery]]></category>

		<guid isPermaLink="false">http://www.danielhall.me/?p=192</guid>
		<description><![CDATA[So today I did about the stupidest thing I could have done at the time. I was planning on clearing my USB hard drive so I could start my new backup plan on it. Of course any Linux geek knows the easy way to erase a hard drive is to do a 'dd if=/dev/zero of=/dev/sdb1'. On almost all my computer there is only one hard drive which maps to /dev/sda. Of course you know exactly where I'm going here don't you? So this is my home server with two hard drive combines into one volume group. The first hard drive is /dev/sda, the second /dev/sdb and the USB hard drive got mapped to /dev/sdc. So in my case that command obliterated the first 125Mb of my second drive before I [...]]]></description>
			<content:encoded><![CDATA[<p>So today I did about the stupidest thing I could have done at the time. I was planning on clearing my USB hard drive so I could start my new backup plan on it. Of course any Linux geek knows the easy way to erase a hard drive is to do a &#8216;dd if=/dev/zero of=/dev/sdb1&#8242;. On almost all my computer there is only one hard drive which maps to /dev/sda. Of course you know exactly where I&#8217;m going here don&#8217;t you? So this is my home server with two hard drive combines into one volume group. The first hard drive is /dev/sda, the second /dev/sdb and the USB hard drive got mapped to /dev/sdc. So in my case that command obliterated the first 125Mb of my second drive before I noticed.</p>
<p>My machine was still running so I knew I hadn&#8217;t wiped anything immediately important. The first thing that I thought of doing was checking what exactly it was that I had wiped and what chance I had of backing up anything before bailing out. Looking at the LVM layout revealed that I&#8217;d probably just destroyed the file system I stored my local Fedora repository on, something I could do without. So I umounted it, removed it from /etc/fstab and did a lvremove. This is exactly where I realised the gravity of the situation. LVM was complaining that it couldn&#8217;t locate one of the physical volumes. Of course it couldn&#8217;t, I&#8217;d just blown away all the metadata for it.</p>
<p>Did you know LVM keeps backups of the metadata? Yes, it keeps them in /etc/lvm/backup (for slightly older copies see /etc/lvm/archive) and you can use this to recover the metadata. I thought a good place to do this would be now, before the reboot that could end it all. Try as I might it was refusing to create a volume that already existed and it also complained about the device being in use. I count myself extremely lucky to be able to do what I did next. To me it felt incredible but when you really think about it it makes sense.</p>
<p>I downloaded the Fedora 11 Live CD and burned it to CD. Yep that&#8217;s right, while knocking on deaths door my machine managed to launch a torrent client, download a 700Mb ISO and burn it to a CD. After that I backed up the /etc/lvm folder to the USB hard drive that caused this mess. Finally I rebooted into the Live environment. The very next step was to recreate the partition table with fdisk.</p>
<p>Then I recreated the physical volume metadata that was destroyed with the following command:</p>
<pre>pvcreate -ff -u DsuvMV-1HVj-SQOU-wZkT-N9M0-LMZd-gPws1U \
 --restorefile /media/usbdisk/lvm/backup/Volgroup00 /dev/sdb1</pre>
<p>This forces the creation of a pv with a specific uuid, ignoring any pvs that exist with the same uuid. It also restores the metadata stored in the restorefile. Follow up with this command to restore the full metadata.</p>
<pre>vgcfgrestore -f /media/usbdisk/lvm/backup/Volgroup00 -v VolGroup00</pre>
<p>Now our LVM metadata is all correct, but at this point we still need to activate the logical volumes.</p>
<pre>vgchange -ay</pre>
<p>Finally you should fsck your logical volumes to make sure everything is working properly and you don&#8217;t get any nasty surprises later. All that is left then is to reboot into your recovered system.</p>
<p>Now thats something they don&#8217;t teach you in RHCE!</p>
<p><strong>Random thought: </strong>Who needs enemies when I have my own stupidity to contend with?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.danielhall.me/2009/08/oh-my-god-i-broke-my-lvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
