Small Q: books are the nourishment of the whole world. There is no book in life, just as there is no sunshine;
Books, as if the birds had no wings. --Shakespeare
=============================== Introduction =================================
LVM: Logical Volume Manager (Logical Volume management), which is a mechanism for managing disk partitions in a Linux environment
Why: Every Linux user will encounter this dilemma when installing Linux: How to accurately evaluate the LVM model when partitioning the system
Allocate the capacity of each hard disk partition, as the system administrator takes into account not only the capacity required for the current partition, but also the
Maximum number of capacity that may be required after partitioning. Because if the estimate is inaccurate, when a partition is not sufficient, the administrator may
To back up the entire system, clear the hard disk, re-partition the hard disk, and then restore the data to the new partition.
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/C7/wKioL1Yo8QjD8cN0AAFpq5JUnt4671.jpg "style=" width : 670px;height:300px; "title=" Dsfs. PNG "width=" 670 "height=" "border=" 0 "hspace=" 0 "vspace=" 0 "alt=" wkiol1yo8qjd8cn0aafpq5junt4671.jpg "/>
Volume Group Volume Group (VG)
The volume group is the highest abstraction layer in LVM and is a memory pool composed of one or more PV.
Physical Volume Physical volume (PV)
A typical physical volume is a hard disk partition, or it can be an entire hard disk or a software RAID volume that has been created, and is the basic storage logic block of LVM.
Contains management parameters that are related to LVM.
Physical Block physical extent (PE)
Physical volumes are stored in units of equal size, the size of which is the same size as the logical volume block in the volume group, and the default is 4MB, so PV
Consists of a basic unit PE of equal size.
Logic Block logical extent (LE)
Logical volumes are stored in "blocks", and the block size of all logical volumes in a volume group is the same. Le is the same size as PE.
Logical Volume Logical Volume (LV)
The logical volume is equivalent to a partition in a non-LVM system, which is established on the VG and is a standard block device on which the file system can be built
Linear mapping
Linear mapping-assigns a range of physical blocks sequentially to logical volumes, such as the LV's LE 1-99 mapping to the Pv1,le 100-347 map
To PV2.
Interleaved mode
Interleaved mode-The logical blocks will be interleaved into different physical volumes, such as the LV's LE 1 mapped to PV1 Pe1,le 2 mapped to PV2 Pe1,le 3 mapped to PV1 PE2: This approach can improve the performance of logical volumes, but the logical volumes created in this way will not
Can be extended in the physical volume in which they reside.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/CA/wKiom1Yo8Nihfpj0AADXFK-MuoI226.jpg "title=" DFGDG. PNG "style=" Float:none; "alt=" wkiom1yo8nihfpj0aadxfk-muoi226.jpg "/>650" this.width=650; "src=" http:// S3.51cto.com/wyfs02/m02/74/c7/wkiol1yo8qlhvz6yaacat5wtu6s559.jpg "title=" 1.PNG "style=" Float:none; "alt=" Wkiol1yo8qlhvz6yaacat5wtu6s559.jpg "/>
============================== Create LVM ================================
The first step is to create the physical file system
Command: fdisk/dev/sdb--create a physical volume and modify the ID to 8e
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/C7/wKioL1Yo8ZqQEadTAAFlSI_zvGg214.jpg "title=" 11.PNG "alt=" Wkiol1yo8zqqeadtaaflsi_zvgg214.jpg "/>
The second step initializes the physical volume to PV
Create PV, add several file systems, and then add a RAID file system
Command: pvcreate/dev/sdb{5,6,7,8,9} ———— Add File system to PV
Pvcreate/dev/md0 ———— Add raid file system to PV
Pvs,pvdisplay ———— View System existing PV
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/74/CB/wKiom1Yo8Z2wCoUrAAER0vML67A094.jpg "title=" 111. PNG "alt=" Wkiom1yo8z2wcouraaer0vml67a094.jpg "/>
Step three create Volume group VG
Add PV to Volume Group, create VG volume group
Command: vgcreate [-s=16m] Test_vg/dev/sdk1/dev/sdl1
Specifies the PE size of the VG volume group name to be added to the VG in PV
Use man to help you see how it's Used
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/74/CB/wKiom1Yo8bvhIWu6AACD690l2WI326.jpg "title=" 111111.PNG "alt=" Wkiom1yo8bvhiwu6aacd690l2wi326.jpg "/>
Looking at the example above, we add PV to the volume group to create the VG
Command: Vgcreate vg0/dev/sdb{5,6,7,8,9}/dev/md0
Vgs,vgdisplay
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/C7/wKioL1Yo8hXRZ_W4AACSv6u6-64853.jpg "title=" 2.PNG " alt= "Wkiol1yo8hxrz_w4aacsv6u6-64853.jpg"/>
Note: The contents of [-s=16m] are optional, modify the default PE unit size, default is 4M, the largest volume group is 256G, modify the defaults
Unit is 16M and the largest volume group unit is 1024G
Command: Vgdisplay TESTVG | grep "Total PE"
Take a look at the default PE size of 4M,PV is 6, the total size of VG is 6.7.G
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/C7/wKioL1Yo8jnyDRHIAABk6lrYONs092.jpg "title=" 22.PNG "alt=" Wkiol1yo8jnydrhiaabk6lryons092.jpg "/>
Some operations for other VG volume groups
Activate VG
The VG and LV are inaccessible until they are activated.
Use man to help you look.
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/C7/wKioL1Yo8lzDLECjAAA582VIBm0816.jpg "style=" float: none; "title=" 2222.PNG "alt=" Wkiol1yo8lzdlecjaaa582vibm0816.jpg "/>
Command: vgchange-a y vg0--activating vg0 Volume Group
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/C7/wKioL1Yo8wWj2WsUAABK9rY1acM196.jpg "title=" FGH. PNG "alt=" Wkiol1yo8wwj2wsuaabk9ry1acm196.jpg "/>
Hibernate the VG0 volume group when the VG is no longer used
Command: vgchange-a n vg0--make it no longer available
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/C7/wKioL1Yo8lzDOoIqAAAvxp8rJ9A557.jpg "title=" 22222. PNG "style=" Float:none; "alt=" wkiol1yo8lzdooiqaaavxp8rj9a557.jpg "/>
Remove VG
Verify that no logical volumes are in the volume group before removing a volume group
Command: vgchange-a n vg0 ———— Dormant volume group
Vgremove vg0 ———— Remove the volume group
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/C7/wKioL1Yo8xuiX6F2AADTeiZYmk8878.jpg "style=" float: none; "title=" 3.PNG "alt=" Wkiol1yo8xuix6f2aadteizymk8878.jpg "/>
Add new PV for VG
When the volume group space is low, you can add a new physical volume to enlarge the VG Volume group capacity, when the command is available vgextend
pvcreate/dev/sdb15--initializing Sdb15 to PV
Vgextend vg0/dev/sdb15--Add sdb15 to the volume group Vg0
Where/dev/sdb15 is the new PV, of course, before this, it should be initialized with Pvcreate
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/CB/wKiom1Yo8vDx_zNNAAGu4tvulgU595.jpg "style=" float: none; "title=" 33.PNG "alt=" Wkiom1yo8vdx_znnaagu4tvulgu595.jpg "/>
Removing PV from VG
Before removing PV, you should confirm that PV is not used by LV
Command: pvdisplay/dev/sdb15--to see if PV is used
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/74/C7/wKioL1Yo8xzTTOVvAADeyKYqLkU852.jpg "style=" float: none; "title=" 333.PNG "alt=" Wkiol1yo8xzttovvaadeykyqlku852.jpg "/>
If this PV is still in use, after confirming that it has not been used, the command vgreduce can be used to remove it from the VG.
Command: Vgreduce vg0/dev/sdb15 ———— remove PV from VG
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/74/CB/wKiom1Yo8yWQrelGAAFeYvo9G7g230.jpg "style=" float: none; "title=" 33333.PNG "alt=" Wkiom1yo8ywqrelgaafeyvo9g7g230.jpg "/>
If there is data on the PV, the data should be transferred to other PV
Note: To remove a PV from the VG, the data from all active PE on it should first be transferred to the other PV, and the new PV must be part of this VG, there is enough space, such as to move the data on the pv1:/dev/md0 to PV2:/DEV/SDB6 available, It is recommended that the data in the LV be backed up before the data is transferred, and if the LV above the PV is interleaved, the transfer process cannot be interrupted.
Command: PVMOVE/DEV/MD0/DEV/SDB6
650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/74/C7/wKioL1Yo81GSCFcpAABK1Xuooz0048.jpg "style=" float: none; "title=" 4.PNG "alt=" Wkiol1yo81gscfcpaabk1xuooz0048.jpg "/>
Day 38th: LVM Logical Volume Management for Linux