{"id":834,"date":"2014-07-04T13:51:12","date_gmt":"2014-07-04T11:51:12","guid":{"rendered":"http:\/\/elkano.org\/blog\/?p=834"},"modified":"2016-04-21T17:21:59","modified_gmt":"2016-04-21T15:21:59","slug":"lvm-recovering-physical-volume-metadata","status":"publish","type":"post","link":"https:\/\/elkano.org\/blog\/lvm-recovering-physical-volume-metadata\/","title":{"rendered":"LVM Recovering Physical Volume Metadata"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p>I had to recover LVM metadata from one physical volume and here are the steps I followed. \u00a0I am not sure why I got this situation, I&#8217;ve used LVM for a long time and this is the only one that I have to recover the metadata. The physical volume was backed by ISCSI lun.<\/p>\n<p>Running pvdisplay command showed\u00a0as no LVM volume:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"enlighter\" data-enlighter-linenumbers=\"false\">$ sudo  pvdisplay \/dev\/mapper\/26a326a6471427270\r\nNo physical volume label read from \/dev\/mapper\/26a326a6471427270\r\nFailed to read physical volume &quot;\/dev\/mapper\/26a326a6471427270&quot;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>ISCSI session was OK:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"enlighter\" data-enlighter-linenumbers=\"false\">$ sudo iscsiadm -m session\r\n\r\ntcp: [25] 172.16.68.51:3260,1 iqn.2012-12:backups\r\ntcp: [26] 172.16.68.151:3260,1 iqn.2012-12:backups\r\ntcp: [27] 172.16.64.10:3260,1 iqn.2012-12:backups\r\ntcp: [28] 172.16.66.10:3260,1 iqn.2012-12:backups<\/pre>\n<p>&nbsp;<\/p>\n<p>multipath\u00a0detected the device paths OK:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"enlighter\" data-enlighter-linenumbers=\"false\">26a326a6471427270 dm-11 SCST_BIO,j2jdqBrpZ2sYmXO3\r\nsize=13T features=&#039;0&#039; hwhandler=&#039;0&#039; wp=rw\r\n`-+- policy=&#039;round-robin 0&#039; prio=0 status=active\r\n|- 30:0:0:0 sdaf 65:240 active ready running\r\n|- 28:0:0:0 sdah 66:16 active ready running\r\n|- 29:0:0:0 sdag 66:0 active ready running\r\n`- 31:0:0:0 sdai 66:32 active ready running<\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"enlighter\" data-enlighter-linenumbers=\"false\">$ sudo  dmsetup ls --tree\r\nvgsatar6_C02-ovznhshare05 (253:52)\r\n\u2514\u250026a326a6471427270 (253:11)\r\n\u251c\u2500 (66:32)\r\n\u251c\u2500 (66:0)\r\n\u251c\u2500 (66:16)\r\n\u2514\u2500 (65:240)\r\n<\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"enlighter\" data-enlighter-linenumbers=\"false\">$ sudo ls -l  \/dev\/vgsatar6_C02\/ovznhshare05\r\n\r\nlrwxrwxrwx 1 root root 8 ene 21 17:06 \/dev\/vgsatar6_C02\/ovznhshare05 -&gt; ..\/dm-52\r\n<\/pre>\n<p>&nbsp;<\/p>\n<p>Also the device was mounted and running fine:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"enlighter\" data-enlighter-linenumbers=\"false\">$ mount\r\n\r\n\/dev\/mapper\/vgsatar6_C02-ovznhshare05 on \/var\/san\/share05 type ext3 (rw,relatime,errors=continue,barrier=0,data=ordered)\r\n<\/pre>\n<p>But, I was sure that if the server was restarted\u00a0the device was going to be lost and not mounted again.<\/p>\n<p>The steps to recover the metadata were as follows:<\/p>\n<p>umount the device:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"enlighter\" data-enlighter-linenumbers=\"false\">$ sudo umount \/var\/san\/share05<\/pre>\n<p>Open your last LVM backup for that VG in \/etc\/lvm\/backup. In my case it was\u00a0\/etc\/lvm\/backup\/vgsatar6_C02<\/p>\n<p>Indentify the UUID for your physical volume in that file:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-linenumbers=\"false\">physical_volumes {\r\n  pv0 {\r\n    id = &quot;1Babrx-VzKI-7Yav-9hGp-2KX2-DRgT-zdpAql&quot;\r\n    device = &quot;\/dev\/mapper\/26a326a6471427270&quot; # Hint only\r\n\r\n    status = [&quot;ALLOCATABLE&quot;]\r\n    flags = []\r\n    dev_size = 27288010752 # 12,707 Terabytes\r\n    pe_start = 2048\r\n    pe_count = 3331055 # 12,707 Terabytes\r\n  }\r\n}<\/pre>\n<p>In my case the Id was &#8220;1Babrx-VzKI-7Yav-9hGp-2KX2-DRgT-zdpAql&#8221;.<\/p>\n<p>Recreate the physical volume again using the information saved in the backup:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"enlighter\" data-enlighter-linenumbers=\"false\">$ sudo pvcreate --uuid &quot;1Babrx-VzKI-7Yav-9hGp-2KX2-DRgT-zdpAql&quot; --restorefile \/etc\/lvm\/backup\/vgsatar6_C02\u00a0\/dev\/mapper\/26a326a6471427270<\/pre>\n<p>&nbsp;<\/p>\n<p>Restore volume group:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"enlighter\" data-enlighter-linenumbers=\"false\">$sudo vgcfgrestore vgsatar6_C02<\/pre>\n<p>Activate logical volume and mount it again:<\/p>\n<p>&nbsp;<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"null\" data-enlighter-theme=\"enlighter\" data-enlighter-linenumbers=\"false\">$ sudo lvchange -ay \/dev\/vgsatar6_C02\/ovznhshare05\u00a0\r\n$ sudo mount \/dev\/vgsatar6_C02\/ovznhshare05\u00a0\/var\/san\/share05<\/pre>\n<p>&nbsp;<\/p>\n<p>And that&#8217;s all, I hope that will help someone.<\/p>\n<p>For more info look at<a href=\"https:\/\/access.redhat.com\/site\/documentation\/en-US\/Red_Hat_Enterprise_Linux\/6\/html\/Logical_Volume_Manager_Administration\/mdatarecover.html\" target=\"_blank\"> redhat documentation\u00a0<\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; I had to recover LVM metadata from one physical volume and here are the steps I followed. \u00a0I am not sure why I got this situation, I&#8217;ve used LVM for a long time and this is the only one that I have to recover the metadata. The physical volume was backed by ISCSI lun. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[117,119,118],"_links":{"self":[{"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/posts\/834"}],"collection":[{"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/comments?post=834"}],"version-history":[{"count":13,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/posts\/834\/revisions"}],"predecessor-version":[{"id":1264,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/posts\/834\/revisions\/1264"}],"wp:attachment":[{"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/media?parent=834"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/categories?post=834"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/tags?post=834"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}