{"id":2629,"date":"2020-04-10T01:47:35","date_gmt":"2020-04-10T01:47:35","guid":{"rendered":"https:\/\/wiki.thomasandsofia.com\/?p=2629"},"modified":"2020-04-10T11:06:09","modified_gmt":"2020-04-10T11:06:09","slug":"6-metadata-recover-of-a-physical-volume","status":"publish","type":"post","link":"https:\/\/wiki.thomasandsofia.com\/?p=2629","title":{"rendered":"6. Metadata Recover of a Physical Volume"},"content":{"rendered":"<p><a href=\"\/5-lvm-snapshots\/\">&lt; 5 LVM Snapshots<\/a> | <a href=\"\/lvm-commands\/\">Commands<\/a> | 7 LVM Attributes &gt;<\/p>\n<h1>33 &amp; 34. Recovering a Faulty Disk<\/h1>\n<p><a href=\"https:\/\/www.udemy.com\/course\/a-complete-guide-on-linux-lvm\/learn\/lecture\/13062490#overview\">https:\/\/www.udemy.com\/course\/a-complete-guide-on-linux-lvm\/learn\/lecture\/13062490#overview<\/a><\/p>\n<p><a href=\"https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2020\/04\/vlm-metadata.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2637\" src=\"https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2020\/04\/vlm-metadata.png\" alt=\"\" width=\"750\" height=\"141\" srcset=\"https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2020\/04\/vlm-metadata.png 750w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2020\/04\/vlm-metadata-300x56.png 300w, https:\/\/wiki.thomasandsofia.com\/wp-content\/uploads\/2020\/04\/vlm-metadata-150x28.png 150w\" sizes=\"auto, (max-width: 750px) 100vw, 750px\" \/><\/a><\/p>\n<ul>\n<li>Overview\n<ul>\n<li>It is possible for the volume group metatdata area of a physical volume to be over-written or deleted.<\/li>\n<li>An error message is displayed indicating the metadata area is incorrect or the system was unable to find a physical volume with the particular UUID.<\/li>\n<\/ul>\n<\/li>\n<li>Symptoms\n<ul>\n<li>lvs -a -o +devices\n<ul>\n<li>Couldn&#8217;t find device with uuid &#8216;gobblety-gook&#8230;.&#8217;<\/li>\n<li>Couldn&#8217;t find all physical volumes for volume group VG<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h2>34 Lab<\/h2>\n<p><a href=\"https:\/\/www.udemy.com\/course\/a-complete-guide-on-linux-lvm\/learn\/lecture\/13062660#overview\" target=\"_blank\" rel=\"noopener\">https:\/\/www.udemy.com\/course\/a-complete-guide-on-linux-lvm\/learn\/lecture\/13062660#overview<\/a><\/p>\n<pre># view # of PV in a VG\r\nvgs\r\n  VG   #OV  #LV  #SN ...\r\n  VG   3    1    0\r\n  ...\r\n# display information about the PEs\r\nvgdisplay -v \/dev\/VG\r\n  ...\r\n  --- Physical Volumes ---\r\n  PV Name  \/dev\/sdg1\r\n  PV UUID  AOSIDq-alE5-...\r\n  PV Status  allocatable\r\n  Total PE \/ Free PE  511 \/ 255\r\n\r\n  PV Name \/dev\/sdh1\r\n  PV UUID B1SmDq-blEy-...\r\n  PV Status allocatable\r\n  Total PE \/ Free PE 511 \/ 255\r\n\r\n  PV Name \/dev\/sdi1\r\n  PV UUID C2SIkq-clEp-...\r\n  PV Status allocatable\r\n  Total PE \/ Free PE 511 \/ 255<\/pre>\n<p>Purposefully ruin a drive&#8217;s metadata<\/p>\n<pre>dd if=\/\/dev\/zero of=\/dev\/sdg1 bs=1024 count=1\r\n# Look at the info again\r\nvgdisplay -v \/dev\/VG\r\n...\r\n--- Physical Volumes ---\r\n  PV Name unknown device\r\n  PV UUID AOSIDq-alE5-...\r\n  PV Status allocatable\r\n  Total PE \/ Free PE 511 \/ 255\r\nlvs -a -o +devices\r\n  WARNING: Device for PV AOSIDq-alE5-... not found or rejected by a filter\r\n  ...\r\n  data LV -wi-a---p- 1.00g\r\n  unknown device(0)<\/pre>\n<h4>How to correct<\/h4>\n<pre># First install a new disk\r\n#\r\n# Partially unmount the filesystem\r\nvgchange -an --partial\r\n# Update the new disk with the old UUID and copy the data\r\npvcreate --uuid \"AOSIDq-alE5-...\" --restorefile \/etc\/lvm\/backup\/VG \/dev\/sdg1\r\n# Restore the remaining metadata\r\nvgcfgrestore \/dev\/VG\r\n# Activate the drive\r\nvgchange -a y \/dev\/VG\r\n# Verify everything is working\r\nvgdisplay -v \/dev\/VG\r\n  ...\r\n  --- Physical Volumes ---\r\n  PV Name \/dev\/sdg1\r\n  PV UUID AOSIDq-alE5-...\r\n  PV Status allocatable\r\n  Total PE \/ Free PE 511 \/ 255<\/pre>\n<p>Using the LVM backup file<\/p>\n<pre># change to the LVM backup directory\r\nsudo su\r\ncd \/etc\/lvm\/backup\/VG\r\n# Show your volume groups\r\nvgs\r\n\u00a0 VG    #PV #LV #SN Attr   VSize   VFree\r\n  myVG    1   1   0 wz--n- 196.96g    0  \r\n# edit that file\r\ncat myVG\r\n<\/pre>\n<h4>Actual File data from my lab<\/h4>\n<pre># Generated by LVM2 version 2.02.180(2)-RHEL7 (2018-07-20): Mon Apr  6 17:42:57 2020\r\n\r\ncontents = \"Text Format Volume Group\"\r\nversion = 1\r\n\r\ndescription = \"Created *after* executing 'lvcreate -n cc138e33-c171-6d3f-e559-f9649d47ad75 -L 201688 XSLocalEXT-cc138e33-c171-6d3f-e559-f9649d47ad75'\"\r\n\r\ncreation_host = \"citrix01\"\t# Linux citrix01 4.19.0+1 #1 SMP Wed Dec 4 13:59:08 UTC 2019 x86_64\r\ncreation_time = 1586212977\t# Mon Apr  6 17:42:57 2020\r\n\r\nXSLocalEXT-cc138e33-c171-6d3f-e559-f9649d47ad75 {\r\n\tid = \"PQfRRm-HJvu-2L3r-ohPX-tWaj-azeD-mwIaxj\"\r\n\tseqno = 2\r\n\tformat = \"lvm2\"\t\t\t# informational\r\n\tstatus = [\"RESIZEABLE\", \"READ\", \"WRITE\"]\r\n\tflags = []\r\n\textent_size = 8192\t\t# 4 Megabytes\r\n\tmax_lv = 0\r\n\tmax_pv = 0\r\n\tmetadata_copies = 0\r\n\r\n\tphysical_volumes {\r\n\r\n\t\tpv0 {\r\n\t\t\tid = \"14dfcf-uhNt-wav7-d1jH-hdOH-fGCr-nABNQi\"\r\n\t\t\tdevice = \"\/dev\/sda3\"\t# Hint only\r\n\r\n\t\t\tstatus = [\"ALLOCATABLE\"]\r\n\t\t\tflags = []\r\n\t\t\tdev_size = 413084303\t# 196.974 Gigabytes\r\n\t\t\tpe_start = 22528\r\n\t\t\tpe_count = 50422\t# 196.961 Gigabytes\r\n\t\t}\r\n\t}\r\n\r\n\tlogical_volumes {\r\n\r\n\t\tcc138e33-c171-6d3f-e559-f9649d47ad75 {\r\n\t\t\tid = \"PpOE7h-qUkF-grNR-2zxi-GMZC-S9HQ-mKhJY6\"\r\n\t\t\tstatus = [\"READ\", \"WRITE\", \"VISIBLE\"]\r\n\t\t\tflags = []\r\n\t\t\tcreation_time = 1586212977\t# 2020-04-06 17:42:57 -0500\r\n\t\t\tcreation_host = \"citrix01\"\r\n\t\t\tsegment_count = 1\r\n\r\n\t\t\tsegment1 {\r\n\t\t\t\tstart_extent = 0\r\n\t\t\t\textent_count = 50422\t# 196.961 Gigabytes\r\n\r\n\t\t\t\ttype = \"striped\"\r\n\t\t\t\tstripe_count = 1\t# linear\r\n\r\n\t\t\t\tstripes = [\r\n\t\t\t\t\t\"pv0\", 0\r\n\t\t\t\t]\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&lt; 5 LVM Snapshots | Commands | 7 LVM Attributes &gt; 33 &amp; 34. Recovering a Faulty Disk https:\/\/www.udemy.com\/course\/a-complete-guide-on-linux-lvm\/learn\/lecture\/13062490#overview Overview It is possible for the volume group metatdata area of a physical volume to be over-written or deleted. An error message is displayed indicating the metadata area is incorrect or the system was unable to ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/wiki.thomasandsofia.com\/?p=2629\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[],"class_list":["post-2629","post","type-post","status-publish","format-standard","hentry","category-logical-volume-manager"],"_links":{"self":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/2629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2629"}],"version-history":[{"count":4,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/2629\/revisions"}],"predecessor-version":[{"id":2639,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=\/wp\/v2\/posts\/2629\/revisions\/2639"}],"wp:attachment":[{"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wiki.thomasandsofia.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}