LVM management-metadata and Partition Table Restoration

Source: Internet
Author: User

In order to view the physical volume, volume group, and logical volume information, we use commands such:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/15/wKiom1OycLLTyrWNAAHuZPqdWNA976.png "Title =" Capture. PNG "alt =" wkiom1oyclltyrwnaahuzpqdwna976.png "/>

This information is placed in the second sector of the physical volume, called the LVM tag. The LVM tag contains the uuid, the device size of the record block, and the location of the record metadata. The LVM metadata contains detailed configurations of the LVM volume group and can be saved in ascll format.

I. Metadata backup

Default location of LVM metadata:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/16/wKiom1OydFDQW1-tAABB0GmUTZw127.jpg "Title =" qq 40704153443.jpg "alt =" wKiom1OydFDQW1-tAABB0GmUTZw127.jpg "/>

You can view the metadata file:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/16/wKioL1Oyexmh0k-6AACEDzCmiwU826.png "style =" float: none; "Title =" Capture. PNG "alt =" wKioL1Oyexmh0k-6AACEDzCmiwU826.png "/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/16/wKiom1Oye0fA5BAuAAB0wCRPczw974.png "style =" float: none; "Title =" Capture 1.png" alt = "wkiom1oye0fa5bauaab0wcrpczw974.png"/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/16/wKioL1OyexmR9ZR1AABNHOHchCk255.png "style =" float: none; "Title =" Capture 2.png" alt = "wkiol1oyexmr9zr1aabnhohchck1_png"/>

There are three methods to back up metadata:

First:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/16/wKiom1OyfGGR7EZcAAAiM0g-ihk207.png "Title =" Capture. PNG "alt =" wKiom1OyfGGR7EZcAAAiM0g-ihk207.png "/>

Dd is used to output device information to a file. However, it is worth noting that the output file is garbled during viewing, when restoring information, we need to manually delete garbled characters in the file.

Second:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/17/wKiom1Oyf0_yh6YAAAAPrX2sfQ0383.png "style =" float: none; "Title =" Capture 1.png" alt = "wkiom1oyf0_yh6yaaaaprx2sfq0383.png"/>

Backup

My environment:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/17/wKiom1OygAHwnIrmAAA0Z-zjMuQ637.png "style =" float: none; "Title =" Capture. PNG "alt =" wKiom1OygAHwnIrmAAA0Z-zjMuQ637.png "/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/16/wKioL1Oyf9PQegYKAABEj-wLsKU430.png "style =" float: none; "Title =" Capture 1.png" alt = "wKioL1Oyf9PQegYKAABEj-wLsKU430.png"/>

Now delete LVM:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/1E/wKiom1OzZMaDdebiAAAabTsuRW4851.png "style =" float: none; "Title =" Capture 1.png" alt = "wkiom1ozzmaddebiaaaabtsurw4851.png"/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/1D/wKioL1OzZJjiXCzOAAAH1pdxE1M522.png "style =" float: none; "Title =" Capture 2.png" alt = "wkiol1ozzjjixczoaaah1pdxe1m522.png"/>

Restore the original configuration by backing up the metadata file:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/1E/wKioL1OzZcmSp1aPAACU0h_Zdqk869.jpg "Title =" qq 40702094645.jpg "alt =" wkiol1ozzcmsp1apaacu0h_zdqk869.jpg "/>

We can see that the LVM has been restored, but a careful friend can see that the marked area in the figure is different from the original one.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/1F/wKiom1OzZlLxyePiAAANuavkLL0578.png "Title =" Capture. PNG "alt =" wkiom1ozzllxyepiaaanuavkll0578.png "/>

If the LVM is not activated, activate it:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/1E/wKioL1OzZqySpYf7AAAeziDUSlA444.png "Title =" Capture. PNG "alt =" wkiol1ozzqyspyf7aaaezidusla444.png "/>

The "-an" parameter is used to stop the LVM activity, which will be discussed later. It is not detailed here.

Third:

Is the metadata file under CP/etc/LVM/backup /.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/1E/wKioL1OzZ9TCy8jxAABhqj5zXOI270.jpg "Title =" 0.jpg" alt = "wkiol1ozz9tcy8jxaabhqj5zxoi270.jpg"/>

Ii. Metadata restoration and Partition Table Restoration

1. The second method above is a common metadata restoration method.

Command for manually backing up volume group metadata:

Vgcfgback-F <backup file path> <logical volume Name>

Command for manual volume group metadata recovery:

Vgcfgrestore-F <backup file path> <logical volume Name>

2. When the disk data is damaged for various reasons and the disk is overwritten by new data, although the data cannot be retrieved, we can still restore the partition table:

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/20/wKiom1OzbX2CiracAAAgsHNIU2s571.png "Title =" Capture. PNG "alt =" wkiom1ozbx2ciracaaagshniu2s571.png "/>

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/23/wKioL1Ozc7SyVOIVAAAjm2_5RKY690.png "Title =" Capture. PNG "alt =" wkiol1ozc7syvoivaaajm2_5rky690.png "/>

Data destroyed

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/21/wKiom1Ozb8DgPYtAAAAwoqpDd58954.png "Title =" Capture. PNG "alt =" wkiom1ozb8dgpytaaaawoqpdd58954.png "/>

Recover PV

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/3E/wKiom1OzlinxyfbkAAA11aZ6urI793.png "Title =" Capture 2.png" alt = "wkiom1ozlinxyfbkaaa11az6uri793.png"/>

Restore VG

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/38/35/wKiom1OzhzryZQqJAAAR8alUTRg715.png "Title =" Capture. PNG "alt =" wkiom1ozhzryzqqja%8alutrg715.png "/>

Successful!

3. If we make PV for the entire disk and then partition the disk with PV for this disk, even though we absolutely cannot do so, data will be lost, however, many new users who have little knowledge about the volume group will still make this mistake. When an error occurs, we can only restore its partition table. As for data guarantee, we cannot:


650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/38/41/wKioL1OznF7hCEMIAAA4_dNQ0bw657.png "Title =" Capture. PNG "alt =" wkiol1oznf7hcemiaaa4_dnq0bw657.png "/>

When an error occurs, the PV previously created on the disk is not recognized.

650) This. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/38/43/wKiom1OznV7RCdbJAAEgVC53txY257.jpg "Title =" qq 40704254311.jpg "alt =" wkiom1oznv7rcdbjaaegvc53txy257.jpg "/>

Refresh Partition Table and re-recognize PV

This article is from the "dripping water and stone" blog and will not be reposted!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.