I. Preface
I have some experiences in learning the basic structure of Aix LVM and will share with you here.
The learning method is to directly view the binary code of the related Device File Based on the OD command, so as to analyze the basic structure of LVM and the effect of LVM advanced commands.
Ii. location where LVM configuration information is stored
The configuration information in LVM, such as VG, LV, and FS, is saved in two parts.
1) in the data block on the disk itself
This part can be directly viewed through low-level LVM commands or OD commands
2) In the ODM Database
The information in the ODM database is directly from the disk data block, which can be viewed by advanced LVM commands or ODM commands.
The LVM command modifies the configuration information in 1) and 2 ).
When the information in the data block is inconsistent with that in the disk, you can use the corresponding synchronization command to update the data block in the disk.
Iii. PV
Each PV header has a reserved area, mainly retaining PVID information.
The PV retention zone is as follows:
0000200 00c9 bbed 1c16 5948 0000 0000 0000
0000220 0000 0000 0000 0000 0000 0000 0000
*
0000300
Note: The 00c9 bbed 1c16 5948 is the PVID.
When the disk is set to Pv = Yes, such a PVID is generated in the reserved area.
When Pv = clear, the PVID in the reserved area is cleared.
The subsequent LVM operations can be continued only when the disk is set to Pv = yes and the PVID is available.
Iv. VG
VG is composed of one or more PVS.
The VG information is stored in vgsa and vgda. When the disk is set to Pv = Yes, The PVID is written in the PV retention area. Another
Reserve part of the external space for vgsa and vgda
It should be noted that the parameters when creating the VG, such as whether large VG is supported, will affect the space allocated to vgsa and vgda.
When creating a VG, write the corresponding parameters to the vgsa and vgda spaces.
Based on the PV quantity in VG, vgda has one or two copies of PV, as shown below:
PV count 1 # PV 2 # PV 3 # PV
1 vgda count 2
2 vgda count 2 1
3 vgda count 1 1 1
Examples of vgsa content are as follows:
Hexadecimal format
0010000 4667 a0e6 2462 3f5d 0000 0000 0000
0010010 0000 0000 0000 0000 0000 0000 0000
*
0010fe0 0000 0000 0000 0000 0000 0000 0001
0010ff0 0000 0000 0000 0000 a0e6 4667 3f5d
Examples of vgda content are as follows:
Hexadecimal format
0011000 4667 a33b 2aba 553c 00c2 2f2f 0000 4c00
0011010 0000 0113 04cc 9a47 0009 0100 001c 0002
0011020 0003 0832 0000 0001 0001 0000 0000
0011030 0000 0832 0000 0000 0000 0000 0000
0011040 0000 0000 0000 0000 0000 0000 0000
*
ASCII character format
0113200 h d 5/0/0/0/0/0/0/0/0/0/0/0/0/0
0113210/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0
*
0113240 h d 6/0/0/0/0/0/0/0/0/0/0/0/0/0
0113250/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0
*
0113280 h d 8/0/0/0/0/0/0/0/0/0/0/0/0/0
0113290/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0
*
01132c0 h d 4/0/0/0/0/0/0/0/0/0/0/0/0/0/
01132d0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/
*
0113300 h d 2/0/0/0/0/0/0/0/0/0/0/0/0/0
0113310/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0
Comparing the output results of lsvg, we can see that all VG information is included in vgsa and vgda.
For example:
0011000 4667 a33b 2aba 553c 00c2 2f2f 0000 4c00
0011010 0000 0113 04cc 9a47 0009 0100 001c 0002
The 00c2 2f2f 0000 4c00 0000 0113 04cc 9a47 in is vgid
The LV name in VG is also included.
Therefore, the content in the ODM is derived from vgsa and vgda.
Exportvg only deletes VG-related information from the ODM, but when hdiskx is viewed with OD, the above vgda information is still
Therefore, when importvg exists, the VG information is re-written to the ODM Based on the vgda information.
V. lv
Divides LV under VG for FS or raw Devices
The basic unit of LV allocation is logical block.
The Logical Block No. 0 of each LV header is used as lvcb to save the LV configuration information.
Lvcb content example:
ASCII code
0000000 a I x l v c B/0/0 J F S/0/0/0
0000010/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0
0000020/0/0/0/0/0/0/0/0/0/0 0 0 C 2 F
0000030 2 F 0 0 0 4 C 0 0 0 0 0 0 0 1
0000040 1 3/0 h d 1/0/0/0/0/0/0/0/0/0/0
0000050/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0
*
0000080/0/0/0 T h u J u n 7 0 6
0000090: 0 8: 4 4 2 0 0 7/n/0/0/0/0
00000a0/0 T h u J u n 7 0 6: 0
00000b0 8: 4 4 2 0 0 7/n/0/0/0/0/0 2
00000c0 2 F 2 F 4 C 0 0/0 y m c/0 y/0
00000d0/0 001/0 001/h o m e/0/0/0/0/0/0/0
0/0 E0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/
We can see that lvcb has mount points and other related information.
After lvcb is damaged, you can use the putlvcb command to fix it, or directly modify the binary file to fix it.
6. FS
The configuration information of FS is saved in the super block. Each fshas two Super blocks.
The primary super block is in the logic block No. 1, and the secondary super block is in the logic block No. 31.
Example of super block content:
ASCII format
0001000 e 207! C/0/0/0/0/0/0 @/0/0/0/0 003
0001010/0/B/0/0 020/0/0/0/h o m e/0/h
0001020 o m e/0/0/n/0 003 001/0/0/0 f g? ?
0001030/0/0/0 001/0/0 002/0/0/0/B/0/0/0/0/0
0001040/0/0/0/0/0/f/0/0/0/0/0 f g? 025
0001050/0/0/0/0 f g? ? /0/0/0/0/0/0/0/0
0001060/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0/0
*
0001c10/0/0/0/0/0/0/0/0
0001c6
Hexadecimal format
0001000 6587 2143 0000 0000 0000 4000 0000
0001010 0008 0000 1000 0000 2f68 6f6d 6500 2f68
0001020 6f6d 6500 000a 0003 0100 0000 4667 a0f2
0001030 0000 0001 0000 0200 0000 0800 0000
0001040 0000 0000 000c 2000 0000 0000 4667 a215
0001050 0000 0000 4667 a1ae 0000 0000 0000
0001060 0000 0000 0000 0000 0000 0000 0000
*
0002000
Comparing LSFS results, we can also see the definition of each byte in the super block.
Note: 6587 2143 is a magic number. If CRFs uses the default parameter, the magic number is 4321 8765.
If the primary super block is damaged, you can use the DD copy super block to repair it, or directly edit the binary file to fix it.
Recovery after the FS is deleted by mistake
If you use rmfs to accidentally delete FS, you only delete the information in lvcb. The information in the super block remains unchanged, and the data in FS does not change.
So long as no new data is written to these spaces, it can be repaired.
The method is: follow the original mklv parameter to restore information in lvcb. After editing/etc/filesystem, you can mount FS without data loss.
VII. Summary
The above is my understanding of LVM. The main Commands are as follows:
# OD-x/C-N 64/dev/hdisk1 + 0200 | more PV reserved area
# OD-x/C/dev/hdisk1 + 0x10000 | more vgsa
# OD-x/C/dev/hdisk1 + 0x11000 | more 1 # vgda
# OD-x/C/dev/hdisk1 + 0x118400 | more 2 # vgda
# OD-C/X/dev/myfs00 + 0x1000 main super block
# OD-CX/dev/myfs00 + 0x1f000 super block
We recommend that you use od to view the binary code of the device file during LVM operations, so that you can better understand the LVM life.
To improve the performance of LVM.